fix(qt): auto-close Plugins manager, read-only field styling, RLock-safe heirs persistence
GUI / plugin lifecycle: - Auto-close Electrum's native 'Electrum Plugins' manager dialog after the BAL plugin is hot-enabled. Electrum 4.7.x no longer calls the old init_qt hook, so the close is now triggered from the create_status_bar, init_menubar and load_wallet hooks (fired when reload_windows() recreates the window). - Robust dialog matching (isinstance / class name / localized window title) to cope with zipimport module-identity mismatches. - Robust dismissal of the modal dialog (reject()/done()/close()) with a retry schedule [400, 800, 1500] ms; if it still cannot be closed, fall back to bringing it to the front (showNormal/raise_/activateWindow) so it never lingers hidden in the background. Counting only visible top-levels avoids treating an already-closed dialog as still open. Read-only field styling: - Paint the locked Delivery time / Check Alive date editors and the mining-fee spinbox with a light-grey background (#f0f0f0) so the user can see at a glance that they are not editable outside the 'Build your will' wizard; the styling is cleared when the fields are made editable again. Pickle/RLock crash on 'Build will': - heirs.save() now sanitises the heirs mapping via _json_safe() before handing it to json_db.put(), which deep-copies the value. A live runtime object (holding a threading.RLock) slipping into an heir value previously raised 'TypeError: cannot pickle _thread.RLock object' and aborted the task; such values are now coerced to str and logged with their path. - init_heirs_to_locktime() coerces the locktime to a plain serializable scalar. - log_error() now accepts both a sys.exc_info() triple and a single exception instance, fixing the secondary 'TypeError object is not subscriptable' that masked the real error.
This commit is contained in:
committed by
steal
parent
5b334b4193
commit
4e027d9e8b
@@ -432,11 +432,26 @@ class BalWindow:
|
||||
self.bal_plugin.WILL_SETTINGS.set(self.will_settings)
|
||||
|
||||
def init_heirs_to_locktime(self, multiverse=False):
|
||||
#pass
|
||||
for heir in self.heirs:
|
||||
h = self.heirs[heir]
|
||||
if not multiverse:
|
||||
self.heirs[heir] = [h[0], h[1], self.will_settings["locktime"]]
|
||||
if multiverse:
|
||||
return
|
||||
# Coerce the locktime to a plain serializable scalar: will_settings is
|
||||
# read from Electrum's config and a non-primitive value here would end
|
||||
# up inside the heirs dict and break json_db persistence (this was one
|
||||
# path to the "cannot pickle '_thread.RLock' object" error).
|
||||
locktime = self.will_settings["locktime"]
|
||||
if not isinstance(locktime, (int, float, str)):
|
||||
locktime = str(locktime)
|
||||
# Iterate over a snapshot of the keys: assigning to self.heirs[...]
|
||||
# triggers Heirs.__setitem__ -> save(), which mutates the mapping while
|
||||
# we iterate it. Building the new values first and applying them after
|
||||
# the loop avoids "dict changed size during iteration" and the repeated
|
||||
# save() on every heir.
|
||||
updates = {
|
||||
heir: [self.heirs[heir][0], self.heirs[heir][1], locktime]
|
||||
for heir in list(self.heirs)
|
||||
}
|
||||
for heir, value in updates.items():
|
||||
self.heirs[heir] = value
|
||||
|
||||
def init_class_variables(self):
|
||||
if not self.heirs:
|
||||
|
||||
Reference in New Issue
Block a user