Martin, thanks by your advices, I finally get it.<br><br>I reorder things this way (just like QGIS do the same things):<br><br>Add Layer: <br><br> * Viewer Class: Calls the loadShapefile method from Load Class.<br> * Load Class: Add layer to QgsMapLayerRegistry.<br>
* Legend Class: ( SLOT to layerWasAdded SIGNAL ) <br> + Add new QTreeWidgetItem.<br> + Update the canvas layer set. (Before, the canvas layer set was updated on Load Class)<br><br>
Remove Layer: ( Before, a for did the RemoveItem, the remove from QgsMapLayerRegistry and the update canvas layer set )<br> <br> * Legend Class: Remove layer from QgsMapLayerRegistry.<br> * Legend Class: Remove the QTreeWidgetItem.<br>
* Legend Class: Update the canvas layer set. <br><br>Now the app works with SIGNAL-SLOT mechanism, like it should be.<br><br>Germán<br><br><br><div class="gmail_quote">El 16 de junio de 2009 10:44, Germán Carrillo <span dir="ltr"><<a href="mailto:carrillo.german@gmail.com">carrillo.german@gmail.com</a>></span> escribió:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Well, I thought this order would do those things:<div class="im"><br><br> self.layers.remove( i )
<br> QgsMapLayerRegistry.instance().removeMapLayer( i.layer().getLayerID() )
<br><div> self.canvas.setLayerSet( self.layers )
</div><br></div>Anyway, I did the two lines swap and get the segmentation fault again.<br><br>Germán <br><br><div class="gmail_quote">El 16 de junio de 2009 10:04, Martin Dobias <span dir="ltr"><<a href="http://wonder.sk" target="_blank">wonder.sk</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>></span> escribió:<div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>2009/6/16 Germán Carrillo <<a href="mailto:carrillo.german@gmail.com" target="_blank">carrillo.german@gmail.com</a>>:<br>
</div><div>> Thanks Martin, but I remove the layer from the layerSet before removing from<br>
> QgsMapLayerRegistry. So, when I update the layer set in canvas, the layer<br>
> doesn't exists.<br>
<br>
</div>From your code I see you only remove the layer from the self.layers<br>
dictionary. But canvas (resp. map renderer class) still thinks that<br>
the layer exists.<br>
<font color="#888888"><br>
Martin<br>
</font></blockquote></div></div></div><br><br clear="all"><div><div></div><div class="h5"><br>-- <br>-----------<br> |\__ <br>(:>__)(<br> |/ <br><br>Soluciones Geoinformáticas Libres <br>
<a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br>
<br>
</div></div></blockquote></div>-- <br>-----------<br> |\__ <br>(:>__)(<br> |/ <br><br>Soluciones Geoinformáticas Libres <br><a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a><br>
<br>