Bug report #3468

Missing layer in project means I can't load project at all

Added by Aren Cambre over 13 years ago. Updated over 12 years ago.

Status:Closed
Priority:Low
Assignee:Tim Sutton
Category:Project Loading/Saving
Affected QGIS version:master Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed
Crashes QGIS or corrupts data:No Copied to github as #:13528

Description

I have a project with 5 layers. One is a ShapeFile that I inadvertently deleted.

When the project loads, I get a QGIS Project Read Error dialog. See attached image. If I select Cancel, then the entire project is unloaded. If I press OK but cannot locate the ShapeFile (and I can't because, again, I deleted it) and hit Cancel in the file browsing dialog, then the project also unloads.

If I press Cancel, or if I press OK but cannot find the project, I should at least have the project loaded without the missing layer. Right now, my project is completely unusable until I restore the ShapeFile.

qgis_error.png (17.7 KB) Aren Cambre, 2011-02-04 08:13 PM

History

#1 Updated by Nathan Woodrow over 13 years ago

I agree. This is not really best way to handle this kind of error. IMO a better approach would be to load the project but show some kind of missing icon next to the item in the legend and/or disable the item. Double clicking should open dialog to restore correct path.

#2 Updated by Jürgen Fischer over 13 years ago

The layers which are existing are loaded in mapcanvas and when it found any
missing layer the added layers are getting removed I went through the source
code , But I could not found the LINE of CODE , which does the function of
removing the added layers ?. Can anyone help me to find the LINE of code ,
which help me to fix the BUG ?.

For missing layer the QgsMapLayer::readXML failed (because the data provider
fails to initialize) and the layers aren't added to the map layer registry:

http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsproject.cpp#L715

All such layer nodes are collected and later passed to

http://trac.osgeo.org/qgis/browser/trunk/qgis/src/gui/qgsprojectbadlayerguihandler.cpp#L16

which tries to update the datasource and reread the bad layer node.

#3 Updated by Tim Sutton about 13 years ago

Hi

I committed the patch supplied by Sunilraj 7cf6c6ea (SVN r15333) which partially addresses this. Sunil, note that if you choose 'OK' then 'Cancel' on the subsequent dialog, the project is returned to blank - I'm not sure if that would be expected behavior. I think it would be better to revert to 'ignore missing' behaviour if cancel is pressed on the file selection dialog.

I also tidied up the dialog wording a little in 66a55eb7 (SVN r15334).

Regards

Tim

#4 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#5 Updated by Jürgen Fischer over 12 years ago

  • Crashes QGIS or corrupts data set to No
  • Status changed from Open to Closed
  • Affected QGIS version set to master
  • Pull Request or Patch supplied set to No
  • Resolution set to fixed

superceded by new dialog.

Also available in: Atom PDF