|
2 | 2 | import sys |
3 | 3 | import typing |
4 | 4 |
|
5 | | -from lib.panels.mainWindow import MainWindow |
6 | | -from logger import setup_logging, LogManager |
7 | | -from PyQt6 import QtCore, QtGui, QtWidgets |
| 5 | +from logger import CrashHandler, LogManager, install_crash_handler, setup_logging |
| 6 | + |
| 7 | +install_crash_handler() |
| 8 | + |
| 9 | +from lib.panels.mainWindow import MainWindow # noqa: E402 |
| 10 | +from PyQt6 import QtCore, QtGui, QtWidgets # noqa: E402 |
| 11 | + |
| 12 | + |
| 13 | +class BlocksScreenApp(QtWidgets.QApplication): |
| 14 | + """QApplication subclass that routes unhandled slot exceptions to CrashHandler.""" |
| 15 | + |
| 16 | + def notify(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool: # type: ignore[override] |
| 17 | + try: |
| 18 | + return super().notify(a0, a1) |
| 19 | + except Exception: |
| 20 | + exc_type, exc_value, exc_tb = sys.exc_info() |
| 21 | + handler = CrashHandler._instance |
| 22 | + if handler is not None and exc_type is not None and exc_value is not None: |
| 23 | + handler._exception_hook(exc_type, exc_value, exc_tb) |
| 24 | + return False |
| 25 | + |
8 | 26 |
|
9 | 27 | QtGui.QGuiApplication.setAttribute( |
10 | 28 | QtCore.Qt.ApplicationAttribute.AA_SynthesizeMouseForUnhandledTouchEvents, |
@@ -46,7 +64,7 @@ def on_quit() -> None: |
46 | 64 | ) |
47 | 65 | _logger = logging.getLogger(__name__) |
48 | 66 | _logger.info("============ BlocksScreen Initializing ============") |
49 | | - BlocksScreen = QtWidgets.QApplication([]) |
| 67 | + BlocksScreen = BlocksScreenApp([]) |
50 | 68 | BlocksScreen.setApplicationName("BlocksScreen") |
51 | 69 | BlocksScreen.setApplicationDisplayName("BlocksScreen") |
52 | 70 | BlocksScreen.setDesktopFileName("BlocksScreen") |
|
0 commit comments