[QGIS-Developer] how to warn user when when reading project XML

Denis Rouzaud denis.rouzaud at gmail.com
Mon Feb 5 12:33:40 PST 2018


Hi all,

I am wondering what's the best way to warn the user when reading XML is not
going as expected i.e. when an error is encountered.

Here is the path to the method I want to warn from:

QgsProject::read
QgsProject::readProjectFile
QgsProject::_getMapLayers
QgsProject::addLayer
QgsMapLayer::readLayerXML
QgsVectorLayer::readXML
QgsVectorLayer::readSymbology
QgsEditFormConfig::readXML

I see only two solutions:

1. Using success return value and some errorMessage.
 This is partly done in readSymbology but totally incomplete (always
returns true and errorMessage are not used at all...)
It would require a finer grain than bool as return value (info / warning /
error, probably).
It would probably be a a list of error messages.

2. Emitting signals.
But that means bring the connections all the way up to the project by
connecting and disconnecting the map layers and all other objects during
the way down. Moreover, many config object are not QObjects.

To me solution 1. sounds nicer but is an API break.
The small feature I am working on is targeted to 3.2 si I would need to set
this in place prior to release.

Is there somehting I am missing?

Cheers,
Denis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180205/8bca6fcf/attachment.html>


More information about the QGIS-Developer mailing list