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

Radim Blazek radim.blazek at gmail.com
Wed Dec 18 02:35:04 PST 2013

Thanks for the explanation. Keeping reference to the object returned
by canvas.mapRenderer() helps.

Are you going to fix those problems?

Note: in my case, the error happens on QGIS 2.0.1 64 (Qt 4.8.5) / Win7
64 bit but it is working  on QGIS 2.0.1 32 (Qt 4.7.1) / Win7 64 and XP
32, but that only question of more frequent garbage collector, I


On Wed, Dec 18, 2013 at 5:27 AM, Martin Dobias <wonder.sk at gmail.com> wrote:
> 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