<div dir="ltr">Hi<div class="gmail_extra"><br><br>Another regression / change in behaviour between legend in 2.x and master is that layers added in python are not focussed in the legend. This breaks some of our InaSAFE stuff that expects this behaviour.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Good:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="http://storage8.static.itmages.com/i/14/0604/h_1401898037_8549074_84a270face.png">http://storage8.static.itmages.com/i/14/0604/h_1401898037_8549074_84a270face.png</a></div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Bad:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="http://storage9.static.itmages.com/i/14/0604/h_1401898084_4943485_004d455ff0.png">http://storage9.static.itmages.com/i/14/0604/h_1401898084_4943485_004d455ff0.png</a></div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Regards</div><div class="gmail_extra"><br></div><div class="gmail_extra">Tim<br><br><br><div class="gmail_quote">On Wed, Jun 4, 2014 at 10d:52 PM, Martin Dobias <span dir="ltr"><<a href="mailto:wonder.sk@gmail.com" target="_blank">wonder.sk@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Hugo<br>
<div class=""><br>
On Wed, Jun 4, 2014 at 10:00 PM, Hugo Mercier <<a href="mailto:hugo.mercier@oslandia.com">hugo.mercier@oslandia.com</a>> wrote:<br>
> Some issues :<br>
><br>
> - passing 'false' to the 'addToLegend' parameter of<br>
> QgsMapLayerRegistry::addMapLayer (in Python) still adds the layer to the<br>
> legend, apparently<br>
<br>
</div>Fixed.<br>
<div class=""><br>
> - QgsLayerTreeGroup.insertLayer( 0, layer ) gives strange things in<br>
> Python (crash of qgis). Doing insertChildNode( 0, QgsLayerTreeLayer(<br>
> layer ) ), or storing the object returned by insertLayer solves the<br>
> problem. It seems to be related to the way Python garbage collects (?)<br>
<br>
</div>Fixed.<br>
<div class=""><br>
> Just a remark on the API : if layers must be added first to the<br>
> MapLayerRegistry before being added to the legend, then why removing a<br>
<br>
</div>Layers do not need to be added to map layer registry first. A layer<br>
can exist in the layer tree even without being loaded.<br>
<div class=""><br>
> layer from the legend makes it removed from the registry and only if it<br>
> is the only one remaining ?<br>
<br>
</div>Otherwise the layer would be removed from the layer tree and it would<br>
never get deleted.<br>
<br>
If you create your own layer tree, you will not have this behaviour<br>
unless you use it with map layer registry bridge.<br>
<br>
For the future (QGIS 3), I'd like to see the following:<br>
- map layer registry will not be used explicitly by client code<br>
(calling addMapLayer/removeMapLayer methods)<br>
- all map layers will be automatically added to the map layer registry<br>
when constructed - and removed when deleted<br>
- if client code will want to add a map layer to layer tree, it would<br>
do it by itself<br>
<br>
Thanks for testing!<br>
<br>
Cheers<br>
<span class=""><font color="#888888">Martin<br>
</font></span><div class=""><div class="h5">_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Tim Sutton - QGIS Project Steering Committee Member<br>==============================================<br>Please do not email me off-list with technical<br>

support questions. Using the lists will gain<br>more exposure for your issues and the knowledge<br>surrounding your issue will be shared with all.<br><br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>

==============================================</div>
</div></div>