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

Denis Rouzaud denis.rouzaud at gmail.com
Thu Feb 13 04:56:33 PST 2014

On 13. 02. 14 12:45, Radim Blazek wrote:
> 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?
I would say yes too. But, I would ask confirmation to people more aware 
than me. There should be some reading this ;)


> Radim

More information about the Qgis-developer mailing list