From 6190498dfc332617d089a388aa60bce39b903c8c Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 15 Aug 2022 08:59:54 +0200 Subject: [PATCH] qml: add setters to QEAmount to allow updating values, as replacing QEAmount instances makes Qt unhappy in a few cases when it still holds references to the old instance, which happened occasionally in e.g. qetxfinalizer --- electrum/gui/qml/qetypes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/electrum/gui/qml/qetypes.py b/electrum/gui/qml/qetypes.py index 28a231ed9..52344ed28 100644 --- a/electrum/gui/qml/qetypes.py +++ b/electrum/gui/qml/qetypes.py @@ -36,6 +36,12 @@ class QEAmount(QObject): return 0 return self._amount_sat + @satsInt.setter + def satsInt(self, sats): + if self._amount_sat != sats: + self._amount_sat = sats + self.valueChanged.emit() + @pyqtProperty('qint64', notify=valueChanged) def msatsInt(self): if self._amount_msat is None: # should normally be defined when accessing this property @@ -43,6 +49,12 @@ class QEAmount(QObject): return 0 return self._amount_msat + @msatsInt.setter + def msatsInt(self, msats): + if self._amount_msat != msats: + self._amount_msat = msats + self.valueChanged.emit() + @pyqtProperty(str, notify=valueChanged) def satsStr(self): return str(self._amount_sat) @@ -55,6 +67,12 @@ class QEAmount(QObject): def isMax(self): return self._is_max + @isMax.setter + def isMax(self, ismax): + if self._is_max != ismax: + self._is_max = ismax + self.valueChanged.emit() + @pyqtProperty(bool, notify=valueChanged) def isEmpty(self): return not(self._is_max or self._amount_sat or self._amount_msat)