Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loss of project when cancelling in "Save project as" dialog #15388

Closed
qgib opened this issue Jul 7, 2012 · 2 comments
Closed

Loss of project when cancelling in "Save project as" dialog #15388

qgib opened this issue Jul 7, 2012 · 2 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@qgib
Copy link
Contributor

qgib commented Jul 7, 2012

Author Name: Leyan Ouyang (Leyan Ouyang)
Original Redmine Issue: 5970
Affected QGIS version: master


Steps to reproduce:

  • Start a new project
  • Work on it
  • Quit, which will prompt a dialog to save the project
  • When asked where to save, cancel the dialog (in my case, I realized I needed information from the layers to choose the project name)
  • Qgis will quit anyway, without saving the project

I had a look at the code and based on my understanding, it is enough to change line 3197 of qgisapp.cpp to return false and cancel the operation when no file has been chosen.

diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp
index 92ed138..23c3eec 100644
--- a/src/app/qgisapp.cpp
+++ b/src/app/qgisapp.cpp
@@ -3192,7 +3192,7 @@ bool QgisApp::fileSave()
                      lastUsedDir + "/" + QgsProject::instance()->title(),
                      tr( "QGis files" ) + " (*.qgs *.QGS)" );
     if ( path.isEmpty() )
-      return true;
+      return false;

@qgib
Copy link
Contributor Author

qgib commented Jul 7, 2012

Author Name: Larry Shaffer (Larry Shaffer)


I can confirm this issue exists on Mac 10.7.4 with 1.8.0 and master branch. The supplied patch fixes the issue and logically follows the comment on line # 5630 of /src/app/qgisapp.cpp:

/**
  Prompt and save if project has been modified.
  @return true if saved or discarded, false if cancelled
 */
bool QgisApp::saveDirty()

The supplied patch by Leyan causes saveDirty to return false as if the Cancel button was clicked in the initial dialog, which is the expected result. Loss of work, as reported, is the unexpected result.

A little clarification on reproducing the issue:

  • ...
  • Quit, which will prompt a dialog to save the project
    • Choose to save the project to disk
  • When asked where to save, ...
  • ...

Nice work finding the quick fix Leyan.

@qgib
Copy link
Contributor Author

qgib commented Jul 7, 2012

Author Name: Jürgen Fischer (@jef-n)


applied in 299857e


  • resolution was changed from to fixed
  • status_id was changed from Open to Closed

@qgib qgib added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

No branches or pull requests

1 participant