Ticket #3468 (new bug)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: arencambre Owned by: timlinux
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Project Loading / Saving Version: 1.6.0
Keywords: Cc: aren@…, timlinux
Platform Version: 7 Platform: Windows
Must Fix for Release: No Awaiting user input: no

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?.

Attachments

qgis_error.png Download (17.7 KB) - added by arencambre 2 years ago.

Change History

Changed 2 years ago by arencambre

Changed 2 years ago by NathanW

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.

Changed 2 years ago by sunilkcube

  • owner changed from nobody to sunilkcube

Changed 2 years ago by jef

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.

Changed 2 years ago by timlinux

  • cc timlinux added

Changed 2 years ago by timlinux

  • owner changed from sunilkcube to timlinux

Hi

I committed the patch supplied by Sunilraj r15332 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 r15333.

Regards

Tim

Note: See TracTickets for help on using tickets.