[Qgis-developer] QgsMapLayerRegistry [partially solved]
Michele Mammini
mamminim at yahoo.it
Fri Oct 9 03:33:02 EDT 2009
Hi Germán,
maybe I discover why the system crash...
my plugin have a form that work on the active layer.
On the OK button these operations will be done:
* get the properties of the active layer that
is based on a pg view (like sql, name, ...)
* remove the layer from QGis using the removeMapLayer function
* perform some filter on the data
* create a new view based on the filter
* load a layer based on the view using addMapLayer function
This last command, addMapLayer, togheter with
second one removeMapLayer, create a crash!
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.
To view the new result it is easy to refresh the MapCanvas.
Michele.
At 18.21 08/10/2009, Germán Carrillo wrote:
>Hi Michele.
>
>I guess you must update the canvas layer set
>after remove a layer from QgsMapLayerRegistry.
>
>
>Germán Carrillo
>
>
>2009/10/8 Michele Mammini <<mailto:mamminim at yahoo.it>mamminim at yahoo.it>
>Like in the subject I solved a part of my problem.
>
>The correct code to remove the layer from QGis is:
> currentLayer = self.iface.activeLayer()
> RegIns = QgsMapLayerRegistry.instance()
> RegIns.removeMapLayer(currentLayer.getLayerID())
>
>but it working if i use it in Python Console,
>while QGis crash if I use it in my plugin code
>
>
>
>
>Dear All,
>
>i have a problem with QgsMapLayerRegistry class
>when i try to remove a Layer from QGis.
>
>i use this two code line:
> RegIns = QgsMapLayerRegistry.instance()
> RegIns.removeMapLayer(layerName)
>
>where layerName is set with this command line:
>layerName = self.iface.activeLayer().name()
>
>Do someone know how to solve it?
>
>Thank you Michele.
>
>_______________________________________________
>Qgis-developer mailing list
><mailto:Qgis-developer at lists.osgeo.org>Qgis-developer at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>--
>-----------
> |\__
>(:>__)(
> |/
>
>Soluciones Geoinformáticas Libres
><http://geotux.tuxfamily.org/>http://geotux.tuxfamily.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20091009/da376e52/attachment.html
More information about the Qgis-developer
mailing list