[Client] Exit deterministically when launching the update installer

This commit is contained in:
Lukas Brübach 2026-09-17 20:31:13 +02:00 committed by GitHub
parent 8a97d23e20
commit 4b3e0fcde7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,11 +5,13 @@
#include "../client/network/update/client/release_channel.h" #include "../client/network/update/client/release_channel.h"
#include "../interface/window_main.h" #include "../interface/window_main.h"
#include <QCoreApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QLabel> #include <QLabel>
#include <QMessageBox> #include <QMessageBox>
#include <QProgressBar> #include <QProgressBar>
#include <QPushButton> #include <QPushButton>
#include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QtNetwork> #include <QtNetwork>
#include <version_string.h> #include <version_string.h>
@ -240,8 +242,14 @@ void DlgUpdate::downloadSuccessful(const QUrl &filepath)
// Try to open the installer. If it opens, quit Cockatrice // Try to open the installer. If it opens, quit Cockatrice
if (process.startDetached()) { if (process.startDetached()) {
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice"; 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<MainWindow *>(parent())) {
window->close();
}
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
close(); close();
} else { } else {
setLabel(tr("Error")); setLabel(tr("Error"));