fix: qt: handle main_window.gui_object.timer being None
When closing Electrum with open `ConfirmTxDialog` the following
exception is raised:
```
1319.20 | E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "/home/user/code/electrum-fork/electrum/gui/qt/send_tab.py", line 575, in do_pay_or_get_invoice
self.do_pay_invoice(self.pending_invoice)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/code/electrum-fork/electrum/gui/qt/send_tab.py", line 602, in do_pay_invoice
self.pay_onchain_dialog(invoice.outputs, invoice=invoice)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/code/electrum-fork/electrum/gui/qt/send_tab.py", line 328, in pay_onchain_dialog
tx, is_preview = self.window.confirm_tx_dialog(make_tx, output_value, batching_candidates=candidates)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 1502, in confirm_tx_dialog
return d.run(), d.is_preview
~~~~~^^
File "/home/user/code/electrum-fork/electrum/gui/qt/confirm_tx_dialog.py", line 477, in run
self.stop_editor_updates()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/user/code/electrum-fork/electrum/gui/qt/confirm_tx_dialog.py", line 133, in stop_editor_updates
self.main_window.gui_object.timer.timeout.disconnect(self.timer_actions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'timeout'
```
This can be prevented by checking if `main_window.gui_object.timer` is
None before trying to disconnect it.
This commit is contained in:
@@ -130,7 +130,8 @@ class TxEditor(WindowModalDialog):
|
||||
self._update_widgets()
|
||||
|
||||
def stop_editor_updates(self):
|
||||
self.main_window.gui_object.timer.timeout.disconnect(self.timer_actions)
|
||||
if self.main_window.gui_object.timer is not None:
|
||||
self.main_window.gui_object.timer.timeout.disconnect(self.timer_actions)
|
||||
|
||||
def update_tx(self, *, fallback_to_zero_fee: bool = False):
|
||||
# expected to set self.tx, self.message and self.error
|
||||
|
||||
Reference in New Issue
Block a user