<html>
<body>
Hi Germán,<br><br>
maybe I discover why the system crash...<br><br>
my plugin have a form that work on the active layer.<br>
On the OK button these operations will be done:
<ul>
<li>get the properties of the active layer that is based on a pg view
(like sql, name, ...)
<li>remove the layer from QGis using the removeMapLayer function
<li>perform some filter on the data
<li>create a new view based on the filter
<li>load a layer based on the view using addMapLayer function
</ul>This last command, addMapLayer, togheter with second one
removeMapLayer, create a crash!<br><br>
I solve the problem in this way: instead of remove the layer, I replace
my view with the new sql but with the same name. <br>
To view the new result it is easy to refresh the MapCanvas.<br><br>
Michele.<br><br>
At 18.21 08/10/2009, Germán Carrillo wrote:<br>
<blockquote type=cite class=cite cite="">Hi Michele.<br><br>
I guess you must update the canvas layer set after remove a layer from
QgsMapLayerRegistry.<br><br>
<br>
Germán Carrillo<br><br>
<br>
2009/10/8 Michele Mammini
&lt;<a href="mailto:mamminim@yahoo.it">mamminim@yahoo.it</a>&gt;<br>

<dl>
<dd>Like in the subject I solved a part of my problem.<br><br>

<dd>The correct code to remove the layer from QGis is:<br>

<dd><font face="Courier New, Courier">&nbsp;&nbsp;&nbsp;&nbsp;
currentLayer = self</i>.iface.activeLayer()<br>

<dd>&nbsp;&nbsp;&nbsp;&nbsp; RegIns = QgsMapLayerRegistry.instance()<br>

<dd>&nbsp;&nbsp;&nbsp;&nbsp;
RegIns.removeMapLayer(currentLayer.getLayerID())<br><br>
</font>
<dd>but it working if i use it in Python Console, while QGis crash if I
use it in my plugin code<br><br>
<br><br>
<br>

<dd>Dear All,<br><br>

<dd>i have a problem with QgsMapLayerRegistry class when i try to remove
a Layer from QGis.<br><br>

<dd>i use this two code line:<br>

<dd><font face="Courier New, Courier">&nbsp;&nbsp;&nbsp;&nbsp; RegIns =
QgsMapLayerRegistry.instance()<br>

<dd>&nbsp;&nbsp;&nbsp;&nbsp; RegIns.removeMapLayer(layerName)<br><br>
</font>
<dd>where layerName is set with this command line:
<font face="Courier New, Courier">layerName =
self</i>.iface.activeLayer().name()<br><br>
</font>
<dd>Do someone know how to solve it?<br><br>

<dd>Thank you Michele.<br><br>

<dd>_______________________________________________<br>

<dd>Qgis-developer mailing list<br>

<dd><a href="mailto:Qgis-developer@lists.osgeo.org">
Qgis-developer@lists.osgeo.org</a><br>

<dd>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" eudora="autourl">
http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br><br>

</dl>-- <br>
-----------<br>
&nbsp; |\__&nbsp; <br>
(:&gt;__)(<br>
&nbsp; |/&nbsp;&nbsp;&nbsp; <br><br>
Soluciones Geoinformáticas
Libres&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a>
<br>
</blockquote></body>
</html>