[Qgis-user] minidump after running script

Luigi Pirelli luipir at gmail.com
Fri Oct 20 01:30:08 PDT 2017


probably the problem is the facto that you use:
https://qgis.org/api/2.18/classQgsFeature.html#ab0a934a1b173ce5ad8d13363c20ef3c8
without cloning geometry... and then you remove the layer => the
geometry pointer is no more valid.

try to do
geom = QgsGeometry( feature.geometry() )
or better
geom = QgsGeometry( feature.constGeometry() )
Luigi Pirelli

**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
* https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
**************************************************************************************************


On 20 October 2017 at 10:08, Reginald <Reginald.Carlier at ingelmunster.be> wrote:
> Hi,
>
> I am trying to make a report by using a script.
> The script looks as follows:
>
> from qgis.PyQt.QtCore import *
> from qgis.PyQt.QtGui import *
> from qgis.PyQt.QtWidgets import *
> import processing
> # selectiepolygoon layer contains one multipolygone
> layer=None
> for lyr in QgsMapLayerRegistry.instance().mapLayers().values():
>     if lyr.name() == "selectiepolygoon":
>         layer = lyr
>         break
>
> # Get the first feature from the layer
> feature = layer.getFeatures().next()
> # fetch geometry
> geom = feature.geometry()
> # remove selectiepolygoon from legend
> my_id = layer.id()
> QgsMapLayerRegistry.instance().removeMapLayers(my_id)
>
> layers = iface.legendInterface().layers()
>
> for layer in layers:
>     layerType = layer.type()
>     if layerType == QgsMapLayer.VectorLayer:
>         for feature in layer.getFeatures():
>             if feature.geometry().intersects(geom):
>                 attr =feature.attributes()
>                 for att in attr:
>                     print (att.value)
>
> When I run this script in my project it terminates with a minidump.
> I suspect that the geom is empty at some point?
> Any idea what is wrong with this script?
>
> Regards,
>
>
>
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list