qml: QEWallet lifecycle fix, remove QEWallet from QEWallet.__instances on destruction.
What changed, and why it matters
This commit fixes a bookkeeping bug in Electrum's mobile/QML wallet interface. When a wallet object is destroyed, it was not being removed from an internal list that tracks all active wallet objects. The commit adds that cleanup step. The commit message says this bug never caused visible problems because the mobile app currently has no way to unload or close a wallet, so the fix is preventive.
Treat as a low-risk maintenance fix. No urgent action needed beyond normal review and testing of wallet destruction paths in the QML GUI. Monitor whether future features enable wallet unloading, which would make this cleanup more relevant.
Security signals we found
Lifecycle cleanup of shared instance registry
Potential stale object reference / use-after-free class of issue
No explicit security claim in commit message
Evidence from the diff
In electrum/gui/qml/qewallet.py, the on_destroy() method now removes self from the QEWallet.__instances class-level list before unregistering callbacks. Previously, destroyed QEWallet objects would remain referenced in __instances, which could lead to stale references, memory retention, or callback-related inconsistencies if wallet unloading were ever enabled. The patch is defensive and minimal (+3 lines).
Changed components
electrum/gui/qml/qewallet.pyQEWallet class instance registryQML/mobile wallet GUI lifecycleInspect captured patch +3 / −0
diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py
index c51d9bb..eeabf52 100644
--- a/electrum/gui/qml/qewallet.py
+++ b/electrum/gui/qml/qewallet.py
@@ -256,6 +256,9 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
self.paymentFailed.emit(key, reason)
def on_destroy(self):
+ if self not in QEWallet.__instances:
+ return
+ QEWallet.__instances.remove(self)
self.unregister_callbacks()
def add_tx_notification(self, tx: Transaction):
Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.