Thanks for your remarks.

You are right, there is no reason to change the parent from "this" to
NULL. I made the changes and attached a new version of the patch.

Claudiu

On Sat, Mar 21, 2015 at 3:55 PM, Lubomir I. Ivanov <[email protected]>
wrote:

> On 20 March 2015 at 23:06, Claudiu Olteanu
> <[email protected]> wrote:
> > Hi there,
> >
> > Here is a patch which fixes the #844 ticket.
>
> lines 31 and 38 of the patch contain trailing whitespace.
> before committing you can use:
> git diff --check
>
> - filename = QFileDialog::getSaveFileName(this, tr("Save file as"),
> default_filename,
> - tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
>
> (1) i know the original wasn't either...
>
> +
> + QFileDialog selection_dialog(NULL, tr("Save file as"), default_filename,
> + tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
> +
>
> (2)...but the second line - tr(....) should be preferable indented
> with spaces like so:
> (should be viewed with a monospace font)
>
> QFileDialog selection_dialog(NULL, tr("Save file as"), default_filename,
>                              tr("Subsurface XML files (*.ssrf *.xml
> *.XML)"));
>
> or with a single tab.
>
> NULL for parent in QFileDialog seems to work, but any reason to change
> that?
> everywhere else in mainwindow.cpp we use "this".
>
> other than these two small remarks, the change seems about right.
>
> lubomir
> --
>
From ec017884596cb2abb9ae14468465abc01c36431f Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <[email protected]>
Date: Sat, 21 Mar 2015 16:17:27 +0200
Subject: [PATCH] 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 <[email protected]>
---
 qt-ui/mainwindow.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 54c0ce7..5b9a87e 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1259,8 +1259,16 @@ 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");
 
-- 
2.1.4

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to