From 9a13fef9591c840969ce2f6f1d61189b56b978be Mon Sep 17 00:00:00 2001 From: Dieter Mayer Date: Mon, 27 Jul 2026 12:44:26 +0200 Subject: [PATCH] Install the log message handler before the application starts qInstallMessageHandler() ran inside the startup worker thread, which is scheduled after QETApp construction - but QETApp's constructor performs the entire startup (collections, editor, opening projects passed on the command line). Everything logged during that window went to the default handler, i.e. stderr, which is invisible in a Windows GUI session: the daily log file ended right after the machine-info block, and exactly the interesting lines - the elements-collection timer and the project load timer from #560 - never reached it. Install the handler synchronously before SingleApplication instead; the worker keeps the old-log cleanup and machine-info dump. The CLI path returns earlier and intentionally keeps plain stderr logging. Verified: a GUI session now logs the full timeline, e.g. 12:37:03.623 Elements collection reload 12:37:03.776 ... finished to be loaded in 0.151 seconds 12:37:04.744 Project "..." (726 KiB) opened in 1.583 seconds (cherry picked from commit 72b1a1d9ec2e3fd3787224759797978d710880bd) --- sources/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sources/main.cpp b/sources/main.cpp index db3accc86..2086dc440 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -246,6 +246,14 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto } } + // Install the log-file message handler BEFORE the application starts: + // QETApp's constructor does the whole startup (collections, editor, + // opening the projects given on the command line), so installing the + // handler afterwards - as was done in the startup worker below - meant + // exactly the interesting lines (collection and project load timers) + // went to stderr, which is invisible in a Windows GUI session. + qInstallMessageHandler(myMessageOutput); + SingleApplication app(argc, argv, true); #ifdef Q_OS_MACOS app.setStyle(QStyleFactory::create("Fusion")); @@ -291,8 +299,6 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto [[maybe_unused]] auto startup_future = QtConcurrent::run([=]() { - // for debugging - qInstallMessageHandler(myMessageOutput); qInfo("Start-up"); // delete old log files of max 7 days old. delete_old_log_files(7);