Merge pull request #11089 from f321x/qml_listmodel_parent
What changed, and why it matters
This change is a small cleanup in Electrum's mobile-style QML user interface. It makes several on-screen data lists (transaction history, addresses, payment requests, invoices, and Lightning channels) properly declare their parent UI object. In Qt/QML, setting a parent helps ensure child objects are cleaned up when the parent is destroyed, which can prevent memory leaks or stale references. There is no direct evidence in the commit that this fixes an active security vulnerability, but it improves object lifetime hygiene and could indirectly prevent UI-related crashes or use-after-free issues.
Treat as a routine hardening fix. Review whether other QML model constructors in the codebase are similarly missing parent arguments, and consider whether unparented models could be reached by untrusted QML content or plugin code. No urgent action required unless additional analysis shows exploitable object lifetime corruption.
Security signals we found
Object lifetime / ownership correction in QML bindings
Potential use-after-free or dangling reference risk from unparented QObject models
Memory leak risk from Python-side references to QML models
No explicit security claim or CVE reference in commit
Evidence from the diff
The commit modifies electrum/gui/qml/qeaddressdetails.py and electrum/gui/qml/qewallet.py to pass parent=self when constructing QETransactionListModel, QEAddressCoinListModel, QERequestListModel, QEInvoiceListModel, and QEChannelListModel. In PyQt/Qt, QObject parentship determines object ownership and automatic deletion. Previously these models were created without an explicit parent, meaning their lifetime was managed only by Python reference counting. If the QML wrapper object was destroyed while Python still held a reference, or vice versa, the model could outlive its associated wallet or address context, potentially leading to dangling references, memory leaks, or inconsistent UI state. The patch is defensive and partial—it only covers two files and does not show related fixes elsewhere.
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 18/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.