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)
This commit is contained in:
Dieter Mayer
2026-07-27 12:44:26 +02:00
parent 66129fd15c
commit 9a13fef959
+8 -2
View File
@@ -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);