Skip to content

Commit

Permalink
Merge pull request #480 from ghutchis/fix-save-empty-crash
Browse files Browse the repository at this point in the history
Fix crash when no selection is made when saving files
  • Loading branch information
ghutchis authored Mar 4, 2024
2 parents 6dae73a + cc7398f commit 782aa89
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void setDefaultViews(MultiViewWidget* viewWidget)
bool anyPluginTrue = false;
// load plugins normally, if all non-ignore are false.
// restore the default behavior
for (auto plugin : sceneModel->scenePlugins()) {
for (ScenePlugin* plugin : sceneModel->scenePlugins()) {
QString settingsKey("MainWindow/" + plugin->objectName());
bool enabled = settings.value(settingsKey, plugin->isEnabled()).toBool();
if (plugin->defaultBehavior() != ScenePlugin::DefaultBehavior::Ignore &&
Expand Down Expand Up @@ -1497,6 +1497,9 @@ bool MainWindow::saveFileAs(bool async)
QFileDialog saveDialog(this, tr("Save chemical file"), dir, filter);
saveDialog.setAcceptMode(QFileDialog::AcceptSave);
saveDialog.exec();
if (saveDialog.selectedFiles().isEmpty()) // user cancel
return false;

QString fileName = saveDialog.selectedFiles().first();

if (fileName.isEmpty()) // user cancel
Expand Down

0 comments on commit 782aa89

Please sign in to comment.