Drop the qApp macro

This commit is contained in:
Veronica Berglyd Olsen
2024-04-03 18:36:37 +02:00
parent 2744fb2fd4
commit c8fe5e6620
19 changed files with 152 additions and 153 deletions
+7 -7
View File
@@ -29,11 +29,11 @@ import logging
from typing import TYPE_CHECKING
from PyQt5.QtGui import QFont, QFontDatabase
from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtGui import QFont, QFontDatabase
from PyQt5.QtWidgets import (
QWidget, qApp, QDialog, QGridLayout, QStyle, QPlainTextEdit, QLabel,
QDialogButtonBox
QApplication, QWidget, QDialog, QGridLayout, QStyle, QPlainTextEdit,
QLabel, QDialogButtonBox
)
if TYPE_CHECKING: # pragma: no cover
@@ -74,7 +74,7 @@ class NWErrorMessage(QDialog):
# Widgets
self.msgIcon = QLabel()
self.msgIcon.setPixmap(
qApp.style().standardIcon(QStyle.SP_MessageBoxCritical).pixmap(64, 64)
QApplication.style().standardIcon(QStyle.SP_MessageBoxCritical).pixmap(64, 64)
)
self.msgHead = QLabel()
self.msgHead.setOpenExternalLinks(True)
@@ -179,14 +179,14 @@ class NWErrorMessage(QDialog):
def exceptionHandler(exType: type, exValue: BaseException, exTrace: TracebackType) -> None:
"""Function to catch unhandled global exceptions."""
from traceback import print_tb
from PyQt5.QtWidgets import qApp
from PyQt5.QtWidgets import QApplication
logger.critical("%s: %s", exType.__name__, str(exValue))
print_tb(exTrace)
try:
nwGUI = None
for qWin in qApp.topLevelWidgets():
for qWin in QApplication.topLevelWidgets():
if qWin.objectName() == "GuiMain":
nwGUI = qWin
break
@@ -209,7 +209,7 @@ def exceptionHandler(exType: type, exValue: BaseException, exTrace: TracebackTyp
logger.critical("Could not close the project before exiting")
logger.critical(formatException(exc))
qApp.exit(1)
QApplication.exit(1)
except Exception as exc:
logger.critical(formatException(exc))