qml: QEAmount returns 0 when amount is undefined
an undefined amount triggers a hard to debug crash when None/undefined is passing the python/QObject boundary, so let's default to 0
This commit is contained in:
@@ -31,10 +31,16 @@ class QEAmount(QObject):
|
|||||||
|
|
||||||
@pyqtProperty('qint64', notify=valueChanged)
|
@pyqtProperty('qint64', notify=valueChanged)
|
||||||
def satsInt(self):
|
def satsInt(self):
|
||||||
|
if self._amount_sat is None: # should normally be defined when accessing this property
|
||||||
|
self._logger.warning('amount_sat is undefined, returning 0')
|
||||||
|
return 0
|
||||||
return self._amount_sat
|
return self._amount_sat
|
||||||
|
|
||||||
@pyqtProperty('qint64', notify=valueChanged)
|
@pyqtProperty('qint64', notify=valueChanged)
|
||||||
def msatsInt(self):
|
def msatsInt(self):
|
||||||
|
if self._amount_msat is None: # should normally be defined when accessing this property
|
||||||
|
self._logger.warning('amount_msat is undefined, returning 0')
|
||||||
|
return 0
|
||||||
return self._amount_msat
|
return self._amount_msat
|
||||||
|
|
||||||
@pyqtProperty(str, notify=valueChanged)
|
@pyqtProperty(str, notify=valueChanged)
|
||||||
|
|||||||
Reference in New Issue
Block a user