From d6b40196146968b606ebf12ce281e6df04787275 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Mon, 20 May 2024 18:33:00 +0200 Subject: [PATCH] Clean up app construction in main entry point --- novelwriter/__init__.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py index 62dd1090..b0c102c8 100644 --- a/novelwriter/__init__.py +++ b/novelwriter/__init__.py @@ -216,28 +216,28 @@ def main(sysArgs: list | None = None) -> GuiMain | None: # Import GUI (after dependency checks), and launch from novelwriter.guimain import GuiMain + if testMode: + # Only used for testing where the test framework creates the app CONFIG.loadConfig() - nwGUI = GuiMain() - return nwGUI + return GuiMain() - else: - nwApp = QApplication([CONFIG.appName, (f"-style={qtStyle}")]) - nwApp.setApplicationName(CONFIG.appName) - nwApp.setApplicationVersion(__version__) - nwApp.setOrganizationDomain(__domain__) - nwApp.setOrganizationName(__domain__) - nwApp.setDesktopFileName(CONFIG.appName) + app = QApplication([CONFIG.appName, (f"-style={qtStyle}")]) + app.setApplicationName(CONFIG.appName) + app.setApplicationVersion(__version__) + app.setOrganizationDomain(__domain__) + app.setOrganizationName(__domain__) + app.setDesktopFileName(CONFIG.appName) - # Connect the exception handler before making the main GUI - sys.excepthook = exceptionHandler + # Connect the exception handler before making the main GUI + sys.excepthook = exceptionHandler - # Run Config steps that require the QApplication - CONFIG.loadConfig() - CONFIG.initLocalisation(nwApp) + # Run Config steps that require the QApplication + CONFIG.loadConfig() + CONFIG.initLocalisation(app) - # Launch main GUI - nwGUI = GuiMain() - nwGUI.postLaunchTasks(cmdOpen) + # Launch main GUI + nwGUI = GuiMain() + nwGUI.postLaunchTasks(cmdOpen) - sys.exit(nwApp.exec()) + sys.exit(app.exec())