From cc7398feb0b05d8c5ecd4840cd0a73663c2514e9 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sat, 2 Mar 2024 22:19:21 -0500 Subject: [PATCH] Fix crash when no selection is made when saving files Fixes #479 Signed-off-by: Geoff Hutchison --- avogadro/mainwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp index e520f007..4118820d 100644 --- a/avogadro/mainwindow.cpp +++ b/avogadro/mainwindow.cpp @@ -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 && @@ -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