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:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user