1
0

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)
This commit is contained in:
Sander van Grieken
2022-08-26 11:57:00 +02:00
parent f398404e04
commit e582ae0486
2 changed files with 7 additions and 2 deletions

View File

@@ -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()

View File

@@ -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