Tue, 24 Jan 2023 16:08:16 +0100
Only try to save images on existing paths
src/EditProductTab13.cpp | file | annotate | diff | comparison | revisions |
--- a/src/EditProductTab13.cpp Tue Jan 24 15:57:13 2023 +0100 +++ b/src/EditProductTab13.cpp Tue Jan 24 16:08:16 2023 +0100 @@ -328,9 +328,20 @@ void EditProduct::downloadImage_clicked() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp"); + QString dirName; + + /* + * First check if the directory stored in the settings file exists. + * It might be on a removable media that was last used ... + * If so, fallback to the user's home directory. + */ + dirName = settings.value("paths/download").toString(); + if (! QDir(dirName).exists()) { + dirName = QDir::homePath(); + } QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), - settings.value("paths/download").toString() + "/" + product->images_list.at(ui->filmStrip->currentRow()).filename, tr("Files (*.png)")); + dirName + "/" + product->images_list.at(ui->filmStrip->currentRow()).filename, tr("Files (*.png)")); if (fileName == 0) { QMessageBox::warning(this, tr("Save File"), tr("No PNG file selected.")); return;