[Qgis-developer] wrapped C/C++ object of type QgsMapRenderer has been deleted

Martin Dobias wonder.sk at gmail.com
Tue Dec 17 20:27:35 PST 2013


Hi Radim

I have encountered this problem recently by chance when working on
multi-threaded rendering. In SIP file for QgsMapCanvas, the
mapRenderer() has /Transfer/ annotation (see commit 0246816e). The
annotation has been obviously added to fix some other problem with
"canvas.mapRenderer().hasCrsTransformEnabled()" idiom. I think the
root of all evil is the fact that "hasCrsTransformEnabled" is both a
signal (with one argument) and an ordinary function (no arguments). My
guess is that SIP probably interprets that combination wrong, it seems
that this is not a problem with other functions/signals.

In any case, /Transfer/ annotation does not seem right. Maybe
/KeepReference/ function annotation would solve the problem (I assume
the python wrapper was getting destroyed too early). Also, having a
signal and a normal function with the same name also does not feel
right - but I guess we need to live with it until 3.0.

Regards
Martin


On Tue, Dec 17, 2013 at 3:28 PM, Radim Blazek <radim.blazek at gmail.com> wrote:
> I have got strange bug report for python plugin, when calling from initGui()
>    iface.mapCanvas().mapRenderer().hasCrsTransformEnabled()
> it gives
>    RuntimeError: wrapped C/C++ object of type QgsMapRenderer has been deleted
>
> From C++ code I see that QgisApp mMapCanvas is created in QgisApp
> constructor and never deleted and QgsMapCanvas mMapRenderer is created
> in QgsMapCanvas constructor and deleted in QgsMapCanvas destructor. I
> don't see how it can happen that QgsMapRenderer is deleted.
>
> Any clue?
>
> Radim
> _______________________________________________
> 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