mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
[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.
This commit is contained in:
parent
de47ddfcae
commit
97c0de876d
1 changed files with 14 additions and 5 deletions
|
|
@ -243,13 +243,22 @@ 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()) {
|
||||||
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
|
// Close the main window synchronously so file locks are released before the NSIS installer
|
||||||
// before the NSIS installer (already launched) starts replacing files, then quit the
|
// (already launched) starts replacing files. This also flushes settings and shuts down the
|
||||||
// application for real in case the close was suppressed (e.g. by a pending prompt).
|
// 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 (auto *window = qobject_cast<MainWindow *>(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();
|
close();
|
||||||
} else {
|
} else {
|
||||||
setLabel(tr("Error"));
|
setLabel(tr("Error"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue