summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-03-21 17:10:55 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-03-21 11:20:46 -0700
commit1982bdb9fc749015631fcff5feaddfefd3606b32 (patch)
tree44852cb351fb4177391aaf821648dc06c268084c /qt-ui/mainwindow.cpp
parent90905601c5e5755a74ab2d867f874710db4091c1 (diff)
downloadsubsurface-1982bdb9fc749015631fcff5feaddfefd3606b32.tar.gz
Implement handler for cancel button of Save As dialog
When an user opened the "Save as" dialog and pressed the cancel button a null string was returned. Therefore the file_save_as function returned an error which was lately shown when the file_save function was called. Now the function checks if the cancel/exit button was pressed and returns. Fixes #844 Reported-by: longjohnsilver Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 54c0ce7f2..2c17648d6 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1259,8 +1259,15 @@ int MainWindow::file_save_as(void)
{
QString filename;
const char *default_filename = existing_filename;
- filename = QFileDialog::getSaveFileName(this, tr("Save file as"), default_filename,
- tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
+ QFileDialog selection_dialog(this, tr("Save file as"), default_filename,
+ tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
+
+ /* if the exit/cancel button is pressed return */
+ if (!selection_dialog.exec())
+ return 0;
+
+ /* get the first selected file */
+ filename = selection_dialog.selectedFiles().at(0);
if (filename.isNull() || filename.isEmpty())
return report_error("No filename to save into");