From 2f6ab8f63bf233e825e9c0690c360375d9ac331b Mon Sep 17 00:00:00 2001 From: ispyisail Date: Wed, 12 Aug 2026 20:31:16 +1200 Subject: [PATCH] Don't drop files handed to a starting instance while the backup prompts are up QETApp's constructor ends with checkBackupFiles(), which opens modal dialogs -- the "restore these files?" prompt, and the crash report offer. Those dialogs run their own event loop, so the constructor does not return until the user answers them. main() still has work to do at that point. In particular this, a few lines later: QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage); While the prompts are up that connection does not exist yet. A second instance launched during the window -- double-clicking a project, or xdg-open, while the first copy is still asking about restore files -- hands its file names over, SingleApplication accepts and delivers them, and nothing is listening. The message is discarded and the second process has already exited, so the file is simply lost with no error. Deferring checkBackupFiles() to the event loop lets the constructor return promptly. main() finishes wiring up, and the prompts appear immediately afterwards exactly as before. Verified with a stale restore file present, sending a project to the running instance while the restore prompt is displayed: before, the file was dropped and never appeared, even after answering the prompt; after, it opens. The restore and backup prompts still appear and still work. Note this is only observable together with the fix for bugtracker #248 -- before that, no file passed to a running instance was opened under any circumstances. --- sources/qetapp.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 01f40e765..3a29ac183 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -164,7 +164,16 @@ QETApp::QETApp() : m_splash_screen -> hide(); } - checkBackupFiles(); + //Deferred so this constructor returns before the prompts appear. + //checkBackupFiles() opens modal dialogs, and main() still has work to + //do once we return -- in particular connecting + //SingleApplication::receivedMessage to receiveMessage(). While those + //prompts were up that connection did not exist yet, so a file handed + //to the already-running instance during start-up was accepted by the + //socket and then dropped on the floor. + QMetaObject::invokeMethod(this, [this]() { + checkBackupFiles(); + }, Qt::QueuedConnection); } /**