[Qgis-developer] Legend refactoring branch merged

Martin Dobias wonder.sk at gmail.com
Wed Jun 4 08:52:52 PDT 2014


Hi Hugo

On Wed, Jun 4, 2014 at 10:00 PM, Hugo Mercier <hugo.mercier at oslandia.com> wrote:
> Some issues :
>
> - passing 'false' to the 'addToLegend' parameter of
> QgsMapLayerRegistry::addMapLayer (in Python) still adds the layer to the
> legend, apparently

Fixed.

> - QgsLayerTreeGroup.insertLayer( 0, layer ) gives strange things in
> Python (crash of qgis). Doing insertChildNode( 0, QgsLayerTreeLayer(
> layer ) ), or storing the object returned by insertLayer solves the
> problem. It seems to be related to the way Python garbage collects (?)

Fixed.

> Just a remark on the API : if layers must be added first to the
> MapLayerRegistry before being added to the legend, then why removing a

Layers do not need to be added to map layer registry first. A layer
can exist in the layer tree even without being loaded.

> layer from the legend makes it removed from the registry and only if it
> is the only one remaining ?

Otherwise the layer would be removed from the layer tree and it would
never get deleted.

If you create your own layer tree, you will not have this behaviour
unless you use it with map layer registry bridge.

For the future (QGIS 3), I'd like to see the following:
- map layer registry will not be used explicitly by client code
(calling addMapLayer/removeMapLayer methods)
- all map layers will be automatically added to the map layer registry
when constructed - and removed when deleted
- if client code will want to add a map layer to layer tree, it would
do it by itself

Thanks for testing!

Cheers
Martin


More information about the Qgis-developer mailing list