[Qgis-developer] How to handle errors when loading the project
Chris Crook
ccrook at linz.govt.nz
Tue Mar 8 20:04:31 EST 2011
Hi All
I've recently had problems with loading project files and think it would be good to change the handling of this a bit!
First a bit of background.
My problems originally came from the changes to the delimited text provider to use Qurl.fromLocalFile as the datasource. I think this is a great change - but it does break existing project files. Also it isn't consistently implemented where the datasource is used in QgsMapLayer and QgsHandleBadLayers. I've submitted a patch to fix this http://trac.osgeo.org/qgis/ticket/3570
But then I had problems with missing symbology information in my project files. I've no idea why this was, but the result was that the layer failed to load, and I got the bad layer handler dialog (great improvement on the original one by one handling BTW). The problem is that this only lets me reselect the file to load into the layer under the assumption that the layer isn't loading because the file has moved. So in my case I can browse and reselect the correct file, but the layer still doesn't load as the symbology is still bad.
This is very confusing from a user's perspective.
There are certainly valid cases, apart from the apparent corruption in my project file, when a symbology won't load. For example a user may have removed a renderer plugin.
I've proposed a short term "fix" in http://trac.osgeo.org/qgis/ticket/3572, which is to revert to a default symbology if the layer cannot be loaded.
End of background.
This raises the question of how to deal well with project load errors. Ideally the user should get a message indicating what the problem is, and some options as to how to deal with it. And this requires a means of recording this information as the project is loading, which is independent of the GUI, and then displaying it and handling it in the GUI.
Where should this be stored?
Thinking aloud now, one option would be to add error/warning status information to the projects and layers. Say a QgsErrorStatus class (StringLists for errors, and warnings?). The QgsProject and QgsMapLayer could have mLoadErrors members with this information (slight problem with layers if the object is deleted when it fails to load!).
So far fairly easy! The question I then have is how to handle the errors. Maybe it needs something more sophisticated like a base error class, and subclasses which can override a handleError method? How would this interface with the GUI? With the project? Or with the project DOM?
Any thoughts on good implementation patterns?
Cheers
Chris
______________________________________________________________________________________________________
This message contains information, which is confidential and may be subject to legal privilege.
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.
Thank you.
______________________________________________________________________________________________________
More information about the Qgis-developer
mailing list