From 4b3e0fcde713b024f8e5b525bc2a0785e961c475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Thu, 17 Sep 2026 20:31:13 +0200 Subject: [PATCH 1/2] [Client] Exit deterministically when launching the update installer --- .../src/interface/widgets/dialogs/dlg_update.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp index 7cf58d3e0..b7d6c5296 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp @@ -5,11 +5,13 @@ #include "../client/network/update/client/release_channel.h" #include "../interface/window_main.h" +#include #include #include #include #include #include +#include #include #include #include @@ -240,8 +242,14 @@ void DlgUpdate::downloadSuccessful(const QUrl &filepath) // Try to open the installer. If it opens, quit Cockatrice if (process.startDetached()) { - QMetaObject::invokeMethod(static_cast(parent()), "close", Qt::QueuedConnection); qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice"; + // Close the main window synchronously so settings are saved and file locks are released + // before the NSIS installer (already launched) starts replacing files, then quit the + // application for real in case the close was suppressed (e.g. by a pending prompt). + if (auto *window = qobject_cast(parent())) { + window->close(); + } + QTimer::singleShot(0, qApp, &QCoreApplication::quit); close(); } else { setLabel(tr("Error")); From 561cadd217577c4b44249599ce06ccce9f356243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 20 Sep 2026 21:07:43 +0200 Subject: [PATCH 2/2] [Client] Only quit when the main window close is accepted Wait for MainWindow::close() to be accepted before quitting after the update installer is launched. When the close is vetoed (a running card DB update, open games, or an unsaved deck), keep running and tell the user the installer is already waiting, instead of exiting over their answer. Also fix the comment so it does not claim settings are saved on the vetoed path. --- .../interface/widgets/dialogs/dlg_update.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp index b7d6c5296..46151481c 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp @@ -243,13 +243,22 @@ void DlgUpdate::downloadSuccessful(const QUrl &filepath) // Try to open the installer. If it opens, quit Cockatrice if (process.startDetached()) { qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice"; - // Close the main window synchronously so settings are saved and file locks are released - // before the NSIS installer (already launched) starts replacing files, then quit the - // application for real in case the close was suppressed (e.g. by a pending prompt). + // Close the main window synchronously so file locks are released before the NSIS installer + // (already launched) starts replacing files. This also flushes settings and shuts down the + // tabs, but only when the close is actually accepted: MainWindow may veto it for a running + // card DB update, an open game, or an unsaved deck. In that case keep running so the user + // can resolve the blocker, and tell them the installer is already waiting. if (auto *window = qobject_cast(parent())) { - window->close(); + if (window->close()) { + QTimer::singleShot(0, qApp, &QCoreApplication::quit); + } else { + QMessageBox::warning(this, tr("Update"), + tr("The update installer is already running and will finish the update once " + "Cockatrice closes. Cockatrice is still busy, so it stays open for now.")); + } + } else { + QTimer::singleShot(0, qApp, &QCoreApplication::quit); } - QTimer::singleShot(0, qApp, &QCoreApplication::quit); close(); } else { setLabel(tr("Error"));