fix infinite loop when card file save fails, instead stop the execution just like the other errors in the call (#4143)

This commit is contained in:
rivten 2020-10-21 16:31:57 +02:00 committed by GitHub
parent 8cbc4c91f6
commit 2081639970
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 44 deletions

View file

@ -607,12 +607,10 @@ void SaveSetsPage::updateTotalProgress(int cardsImported, int /* setIndex */, co
bool SaveSetsPage::validatePage()
{
bool ok = false;
QString defaultPath = SettingsCache::instance().getCardDatabasePath();
QString windowName = tr("Save card database");
QString fileType = tr("XML; card database (*.xml)");
do {
QString fileName;
if (defaultPathCheckBox->isChecked()) {
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
@ -630,12 +628,10 @@ bool SaveSetsPage::validatePage()
return false;
}
if (wizard()->importer->saveToFile(fileName, wizard()->getCardSourceUrl(), wizard()->getCardSourceVersion())) {
ok = true;
} else {
if (!wizard()->importer->saveToFile(fileName, wizard()->getCardSourceUrl(), wizard()->getCardSourceVersion())) {
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
return false;
}
} while (!ok);
return true;
}

View file

@ -144,12 +144,10 @@ void SimpleDownloadFilePage::actDownloadFinished()
bool SimpleDownloadFilePage::saveToFile()
{
bool ok = false;
QString defaultPath = getDefaultSavePath();
QString windowName = getWindowTitle();
QString fileType = getFileType();
do {
QString fileName;
if (defaultPathCheckBox->isChecked()) {
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
@ -167,12 +165,10 @@ bool SimpleDownloadFilePage::saveToFile()
return false;
}
if (internalSaveToFile(fileName)) {
ok = true;
} else {
if (!internalSaveToFile(fileName)) {
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
return false;
}
} while (!ok);
// clean saved downloadData
downloadData = QByteArray();