Browse Source

add excepthooks, hoping to force a backtrace log when qt5 SIGABRTs

patch-4
Sander van Grieken 3 years ago
parent
commit
2c656a0cf7
  1. 19
      electrum/gui/qml/__init__.py

19
electrum/gui/qml/__init__.py

@ -36,6 +36,10 @@ if TYPE_CHECKING:
from .qeapp import ElectrumQmlApplication
class UncaughtException(Exception):
pass
class ElectrumGui(Logger):
@profiler
@ -71,6 +75,9 @@ class ElectrumGui(Logger):
self.timer.setInterval(500) # msec
self.timer.timeout.connect(lambda: None) # periodically enter python scope
sys.excepthook = self.excepthook
threading.excepthook = self.texcepthook
# Initialize any QML plugins
run_hook('init_qml', self)
self.app.engine.load('electrum/gui/qml/components/main.qml')
@ -78,6 +85,18 @@ class ElectrumGui(Logger):
def close(self):
self.app.quit()
def excepthook(self, exc_type, exc_value, exc_tb):
tb = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
self.logger.exception(tb)
self.app._valid = False
self.close()
def texcepthook(self, arg):
tb = "".join(traceback.format_exception(arg.exc_type, arg.exc_value, arg.exc_tb))
self.logger.exception(tb)
self.app._valid = False
self.close()
def main(self):
if not self.app._valid:
return

Loading…
Cancel
Save