mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
Merge 3f3b76d4f0 into ad42d500f5
This commit is contained in:
commit
f4606c801a
1 changed files with 18 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,23 @@ 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 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<MainWindow *>(parent())) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
setLabel(tr("Error"));
|
setLabel(tr("Error"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue