This commit is contained in:
BruebachL 2026-08-24 12:46:15 -07:00 • committed by GitHub
commit 85f024ee65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 43 additions and 9 deletions

View file

@ -1027,7 +1027,7 @@ void MainWindow::createCardUpdateProcess(bool background)
if (updaterCmd.isEmpty()) { if (updaterCmd.isEmpty()) {
QMessageBox::warning(this, tr("Error"), QMessageBox::warning(this, tr("Error"),
tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName)); tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName));
exitCardDatabaseUpdate(); exitCardDatabaseUpdate(false);
return; return;
} }
@ -1039,13 +1039,15 @@ void MainWindow::createCardUpdateProcess(bool background)
} }
} }
void MainWindow::exitCardDatabaseUpdate() void MainWindow::exitCardDatabaseUpdate(bool reload)
{ {
cardUpdateProcess->deleteLater(); cardUpdateProcess->deleteLater();
cardUpdateProcess = nullptr; cardUpdateProcess = nullptr;
statusBar()->clearMessage(); statusBar()->clearMessage();
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); }); if (reload) {
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
}
} }
void MainWindow::cardUpdateError(QProcess::ProcessError err) void MainWindow::cardUpdateError(QProcess::ProcessError err)
@ -1076,16 +1078,21 @@ void MainWindow::cardUpdateError(QProcess::ProcessError err)
break; break;
} }
exitCardDatabaseUpdate(); exitCardDatabaseUpdate(false);
QMessageBox::warning(this, tr("Error"), tr("The card database updater exited with an error:\n%1").arg(error)); QMessageBox::warning(this, tr("Error"), tr("The card database updater exited with an error:\n%1").arg(error));
} }
void MainWindow::cardUpdateFinished(int, QProcess::ExitStatus exitStatus) void MainWindow::cardUpdateFinished(int exitCode, QProcess::ExitStatus exitStatus)
{ {
if (exitStatus == QProcess::NormalExit) { if (exitStatus == QProcess::NormalExit && exitCode == 0) {
SettingsCache::instance().updates().setLastCardUpdateCheck(QDateTime::currentDateTime().date()); SettingsCache::instance().updates().setLastCardUpdateCheck(QDateTime::currentDateTime().date());
exitCardDatabaseUpdate(true);
} else {
exitCardDatabaseUpdate(false);
if (exitStatus == QProcess::NormalExit && exitCode != 0) {
statusBar()->showMessage(tr("Card database update cancelled."), 10000);
}
} }
exitCardDatabaseUpdate();
} }
void MainWindow::actCheckServerUpdates() void MainWindow::actCheckServerUpdates()

View file

@ -130,7 +130,7 @@ private:
return "oracle"; return "oracle";
} }
void createCardUpdateProcess(bool background = false); void createCardUpdateProcess(bool background = false);
void exitCardDatabaseUpdate(); void exitCardDatabaseUpdate(bool reload);
void startLocalGame(const LocalGameOptions &options); void startLocalGame(const LocalGameOptions &options);

View file

@ -91,5 +91,6 @@ int main(int argc, char *argv[])
QTimer::singleShot(0, &wizard, [&wizard]() { wizard.runInBackground(); }); QTimer::singleShot(0, &wizard, [&wizard]() { wizard.runInBackground(); });
} }
return app.exec(); const int execResult = app.exec();
return wizard.wasCancelled() ? 1 : execResult;
} }

View file

@ -110,6 +110,18 @@ void OracleWizard::accept()
QDialog::accept(); QDialog::accept();
} }
void OracleWizard::reject()
{
cancelled = true;
const auto replies = nam->findChildren<QNetworkReply *>();
for (QNetworkReply *reply : replies) {
reply->abort();
}
QDialog::reject();
}
void OracleWizard::enableButtons() void OracleWizard::enableButtons()
{ {
button(QWizard::NextButton)->setDisabled(false); button(QWizard::NextButton)->setDisabled(false);

View file

@ -23,6 +23,11 @@ class OracleWizard : public QWizard
public: public:
explicit OracleWizard(QWidget *parent = nullptr); explicit OracleWizard(QWidget *parent = nullptr);
void accept() override; void accept() override;
void reject() override;
bool wasCancelled()
{
return cancelled;
}
void enableButtons(); void enableButtons();
void disableButtons(); void disableButtons();
void retranslateUi(); void retranslateUi();
@ -74,6 +79,7 @@ private:
QByteArray tokensData; QByteArray tokensData;
QString cardSourceUrl; QString cardSourceUrl;
QString cardSourceVersion; QString cardSourceVersion;
bool cancelled = false;
void migrateOracleSettings(); void migrateOracleSettings();

View file

@ -350,6 +350,10 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
{ {
// check for a reply // check for a reply
auto *reply = dynamic_cast<QNetworkReply *>(sender()); auto *reply = dynamic_cast<QNetworkReply *>(sender());
if (wizard()->wasCancelled()) {
reply->deleteLater();
return;
}
auto errorCode = reply->error(); auto errorCode = reply->error();
if (errorCode != QNetworkReply::NoError) { if (errorCode != QNetworkReply::NoError) {
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString())); QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));

View file

@ -163,6 +163,10 @@ void SimpleDownloadFilePage::actDownloadFinished()
{ {
// check for a reply // check for a reply
auto *reply = dynamic_cast<QNetworkReply *>(sender()); auto *reply = dynamic_cast<QNetworkReply *>(sender());
if (wizard()->wasCancelled()) {
reply->deleteLater();
return;
}
QNetworkReply::NetworkError errorCode = reply->error(); QNetworkReply::NetworkError errorCode = reply->error();
if (errorCode != QNetworkReply::NoError) { if (errorCode != QNetworkReply::NoError) {
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString())); QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));