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

2014-01-16 Thread Radim Blazek
On Wed, Dec 18, 2013 at 5:27 AM, Martin Dobias  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.

I have
* changed QgsMapCanvas mapRenderer() /Transfer/ to /KeepReference/
* added signal QgsMapRenderer::hasCrsTransformEnabledChanged()
* deprecated signal QgsMapRenderer::hasCrsTransformEnabled()

Radim

> Regards
> Martin
>
>
> On Tue, Dec 17, 2013 at 3:28 PM, Radim Blazek  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@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


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

2013-12-19 Thread Martin Dobias
On Wed, Dec 18, 2013 at 5:35 PM, Radim Blazek  wrote:
> Thanks for the explanation. Keeping reference to the object returned
> by canvas.mapRenderer() helps.
>
> Are you going to fix those problems?

Not now (busy with other things)... but the only thing I can think of
is to use /KeepReference/ instead of /Transfer/ for mapRenderer()
call. Feel free to commit such change if it works well.

Martin
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


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

2013-12-18 Thread Radim Blazek
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
think.

Radim

On Wed, Dec 18, 2013 at 5:27 AM, Martin Dobias  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  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@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


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

2013-12-17 Thread Martin Dobias
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  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@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


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

2013-12-17 Thread Radim Blazek
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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer