[Qgis-developer] crash when accessing geometry from Python console

Matthias Kuhn matthias at opengis.ch
Thu Jun 25 01:36:01 PDT 2015


Hi,

The savest option is to use

QgsGeometry( feat.geometry() )

This does currently work and will continue to work in the future once
issue #777 is resolved,

Cheers,
Matthias

On 06/25/2015 09:10 AM, Bernhard Ströbl wrote:
> Hi Martin,
>
> I was not aware of this bug, thanks for pointing me towards it. As
> posted previously I found a workaround but if I use
> geometryAndOwnership() as proposed in #777 do I have to do anything like
> g = None to destroy the geometry or will Python take care of that as
> soon as my script has been finished?
>
> thank you for your help
>
> Bernhard
>
> Am 25.06.2015 um 09:00 schrieb Martin Dobias:
>> Hi Bernhard
>>
>> that's a long standing unresolved issue with python bindings:
>> http://hub.qgis.org/issues/777
>>
>> Regards
>> Martin
>>
>>
>>
>> On Thu, Jun 25, 2015 at 2:43 PM, Bernhard Ströbl
>> <bernhard.stroebl at jena.de> wrote:
>>> Hi everybody,
>>>
>>> I try to do the following from the Python console:
>>> g=iface.activeLayer().selectedFeatures()[0].geometry()
>>> returns a QgsGeometry objekt but as soon as I want to do anything
>>> with it
>>> QGIS crashes (layer is a memory line layer but a PostGIS linestring
>>> layer
>>> behaves the same). Any request like
>>> g.type()
>>> g.length()
>>> g.anything crashes QGIS
>>> g.asPolyline() crash if the line has three vertices, with only two
>>> vertices
>>> it returns an empty array.
>>>
>>> My goal is not the Python console but a plugin; the plugin crashes,
>>> too :-(
>>>
>>> tested with 2.8 on Win7 (64bit) and 2.8 & 2.9 on Ubuntu (64 bit) so it
>>> should not be connected to the geometry overhaul I reckon.
>>>
>>> any help appreciated
>>>
>>> Bernhard
>>>
>>>
>
>
> __________ Information from ESET Mail Security, version of virus
> signature database 11840 (20150625) __________
>
> The message was checked by ESET Mail Security.
> http://www.eset.com
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list