Skip to content

Commit f2ebd88

Browse files
gmmcosta15HugoCLSC
andauthored
bugfix(logger): starts logger before the mainwindow (#196)
* bugfix(logger): starts logger before the mainwindow * fix formatting --------- Co-authored-by: Hugo Costa <hugo.santos.costa@gmail.com>
1 parent f1478cc commit f2ebd88

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

BlocksScreen/BlocksScreen.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
import sys
33
import typing
44

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+
826

927
QtGui.QGuiApplication.setAttribute(
1028
QtCore.Qt.ApplicationAttribute.AA_SynthesizeMouseForUnhandledTouchEvents,
@@ -46,7 +64,7 @@ def on_quit() -> None:
4664
)
4765
_logger = logging.getLogger(__name__)
4866
_logger.info("============ BlocksScreen Initializing ============")
49-
BlocksScreen = QtWidgets.QApplication([])
67+
BlocksScreen = BlocksScreenApp([])
5068
BlocksScreen.setApplicationName("BlocksScreen")
5169
BlocksScreen.setApplicationDisplayName("BlocksScreen")
5270
BlocksScreen.setDesktopFileName("BlocksScreen")

BlocksScreen/lib/panels/networkWindow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3845,4 +3845,3 @@ def show_network_panel(self) -> None:
38453845
self.repaint()
38463846
self.show()
38473847
self._nm.scan_networks()
3848-

0 commit comments

Comments
 (0)