From 74e9c848ccf68cb5a15366e89ce634a1d2a7b8eb Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 12 Aug 2022 14:56:00 +0200 Subject: [PATCH] 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 --- electrum/gui/qml/qetypes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/electrum/gui/qml/qetypes.py b/electrum/gui/qml/qetypes.py index 6d4d9b1ea..28a231ed9 100644 --- a/electrum/gui/qml/qetypes.py +++ b/electrum/gui/qml/qetypes.py @@ -31,10 +31,16 @@ class QEAmount(QObject): @pyqtProperty('qint64', notify=valueChanged) 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 @pyqtProperty('qint64', notify=valueChanged) 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 @pyqtProperty(str, notify=valueChanged)