[Qgis-developer] QgsRubberBand RuntimeError: underlying C/C++ object has been deleted

Radim Blazek radim.blazek at gmail.com
Thu Feb 13 03:45:49 PST 2014


Thanks Denis,

>> However, do you have any idea where the point may be deleted? The
>> points are acquired from QgsGeometry.asPolyline() which returns
>> QVector<QgsPoint>, i.e. list of values. The points are then add to
>> another list: result.extend( pnts[1:-1] ). Is it wrong? The points get
>> deleted with original list?
>
> I suppose you need to do a copy of your point in the result of the snapping.
>
> do: point = QgsPoint( result[0].snappedVertex )
>
> otherwise, result get out of scope at the end of the method and your point
> is deleted.

1) does it mean that
  point = result[0].snappedVertex
does not make a copy? It only creates Python wrapper object
referencing original C++ QgsSnappingResult.snappedVertex member?

2) If a SIP wrapper class A has a member class B and an instance of A
is created in Python,  B member is referenced and reference to A is
deleted is it the A instance deleted by GC including B (which is still
referenced)?

C++: class A { B b; }
SIP: class A { B b; }
Python:
a = A()
b = a.b
a = None
# garbage collector

a and b were deleted?

Radim


More information about the Qgis-developer mailing list