qml: set parent on list models created by QEWallet and QEAddressDetails
What changed, and why it matters
This change fixes how certain list-like data objects in Electrum's mobile-style QML interface are tied to their parent screens. Previously, these objects were only kept alive by Python references and might not be cleaned up promptly when a wallet or address details page was closed. By giving them a proper parent object, they are destroyed together with the page, which also removes their internal callback hooks. This is a cleanup and stability improvement rather than a direct fix for an active exploit, but poor object lifetime management can sometimes lead to crashes or subtle bugs.
Treat as a routine stability/maintenance fix. Review whether the model classes unregister all callbacks and timers in their destructors to confirm the intended cleanup is complete. No urgent security response is indicated based on this commit alone.
Security signals we found
Object lifetime / use-after-free risk reduction
Callback leak prevention via deterministic QObject destruction
Memory/resource cleanup improvement in QML GUI layer
No explicit security claim in commit message or title
Evidence from the diff
The commit sets parent=self on several PyQt/QML list model instances (QETransactionListModel, QEAddressCoinListModel, QERequestListModel, QEInvoiceListModel, QEChannelListModel) created inside QEWallet and QEAddressDetails. Without a QObject parent, these models’ lifetimes were governed solely by Python references, meaning they could outlive their associated UI/controller objects and continue to hold registered callbacks after the owning page was closed. Parenting them ensures C++-side destruction follows the parent object’s lifecycle, unregistering callbacks and freeing resources deterministically. The diff shows only the addition of parent=self and no other logic changes.
Changed components
electrum/gui/qml/qeaddressdetails.pyelectrum/gui/qml/qewallet.pyQETransactionListModelQEAddressCoinListModelQERequestListModelQEInvoiceListModelQEChannelListModelInspect captured patch +11 / −7
### electrum/gui/qml/qeaddressdetails.py
@@ -116,8 +116,12 @@ def setLabel(self, label: str):
@pyqtProperty(QETransactionListModel, notify=historyModelChanged)
def historyModel(self):
if self._historyModel is None:
- self._historyModel = QETransactionListModel(self._wallet.wallet,
- onchain_domain=[self._address], include_lightning=False)
+ self._historyModel = QETransactionListModel(
+ self._wallet.wallet,
+ parent=self,
+ onchain_domain=[self._address],
+ include_lightning=False,
+ )
return self._historyModel
@pyqtSlot()
### electrum/gui/qml/qewallet.py
@@ -306,35 +306,35 @@ def update_sync_progress(self):
@pyqtProperty(QETransactionListModel, notify=historyModelChanged)
def historyModel(self):
if self._historyModel is None:
- self._historyModel = QETransactionListModel(self.wallet)
+ self._historyModel = QETransactionListModel(self.wallet, parent=self)
return self._historyModel
addressCoinModelChanged = pyqtSignal()
@pyqtProperty(QEAddressCoinListModel, notify=addressCoinModelChanged)
def addressCoinModel(self):
if self._addressCoinModel is None:
- self._addressCoinModel = QEAddressCoinListModel(self.wallet)
+ self._addressCoinModel = QEAddressCoinListModel(self.wallet, parent=self)
return self._addressCoinModel
requestModelChanged = pyqtSignal()
@pyqtProperty(QERequestListModel, notify=requestModelChanged)
def requestModel(self):
if self._requestModel is None:
- self._requestModel = QERequestListModel(self.wallet)
+ self._requestModel = QERequestListModel(self.wallet, parent=self)
return self._requestModel
invoiceModelChanged = pyqtSignal()
@pyqtProperty(QEInvoiceListModel, notify=invoiceModelChanged)
def invoiceModel(self):
if self._invoiceModel is None:
- self._invoiceModel = QEInvoiceListModel(self.wallet)
+ self._invoiceModel = QEInvoiceListModel(self.wallet, parent=self)
return self._invoiceModel
channelModelChanged = pyqtSignal()
@pyqtProperty(QEChannelListModel, notify=channelModelChanged)
def channelModel(self):
if self._channelModel is None:
- self._channelModel = QEChannelListModel(self.wallet)
+ self._channelModel = QEChannelListModel(self.wallet, parent=self)
return self._channelModel
nameChanged = pyqtSignal()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.