From dc09810e981908a6141dec8d3a8db8a543cc561c Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 21 Dec 2020 13:48:31 -0600 Subject: [PATCH] Check for filename before selecting Correct an error caught by @davidosterberg -- the non-native QFileDialog did not behave as expected when not provided with a default filename, so that case is now caught and the `selectFile()` call is bypassed. --- src/Gui/FileDialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index a07f13b2bb..f2ddf091e3 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -135,6 +135,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, const QString & filter, QString * selectedFilter, Options options) { QString dirName = dir; + bool hasFilename = false; if (dirName.isEmpty()) { dirName = getWorkingDirectory(); } else { @@ -144,6 +145,9 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, dirName += QLatin1String("/"); dirName += fi.fileName(); } + if (!fi.fileName().isEmpty()) { + hasFilename = true; + } // get the suffix for the filter: use the selected filter if there is one, // otherwise find the first valid suffix in the complete list of filters @@ -207,7 +211,8 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, dlg.setFileMode(QFileDialog::AnyFile); dlg.setAcceptMode(QFileDialog::AcceptSave); dlg.setDirectory(dirName); - dlg.selectFile(dirName); + if (hasFilename) + dlg.selectFile(dirName); dlg.setOptions(options); dlg.setNameFilters(filter.split(QLatin1String(";;"))); if (selectedFilter && !selectedFilter->isEmpty())