Browse Source

qml: add QEAmount.copyFrom(QEAmount) so we can take a new amount object without changing the instance.

This avoids crashes when a QEAmount is already referenced in QML, and then replaced with another instance (e.g. in qetxfinalizer.py)
master
Sander van Grieken 3 years ago
parent
commit
e582ae0486
  1. 4
      electrum/gui/qml/qetxfinalizer.py
  2. 5
      electrum/gui/qml/qetypes.py

4
electrum/gui/qml/qetxfinalizer.py

@ -74,7 +74,7 @@ class QETxFinalizer(QObject):
def amount(self, amount):
if self._amount != amount:
self._logger.debug(str(amount))
self._amount = amount
self._amount.copyFrom(amount)
self.amountChanged.emit()
effectiveAmountChanged = pyqtSignal()
@ -90,7 +90,7 @@ class QETxFinalizer(QObject):
@fee.setter
def fee(self, fee):
if self._fee != fee:
self._fee = fee
self._fee.copyFrom(fee)
self.feeChanged.emit()
feeRateChanged = pyqtSignal()

5
electrum/gui/qml/qetypes.py

@ -77,6 +77,11 @@ class QEAmount(QObject):
def isEmpty(self):
return not(self._is_max or self._amount_sat or self._amount_msat)
def copyFrom(self, amount):
self.satsInt = amount.satsInt
self.msatsInt = amount.msatsInt
self.isMax = amount.isMax
def __eq__(self, other):
if isinstance(other, QEAmount):
return self._amount_sat == other._amount_sat and self._amount_msat == other._amount_msat and self._is_max == other._is_max

Loading…
Cancel
Save