mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Client] Exit deterministically when launching the update installer
This commit is contained in:
parent
8a97d23e20
commit
4b3e0fcde7
1 changed files with 9 additions and 1 deletions
|
|
@ -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"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue