[PyQt] Conversion to wrong SubClass

Phil Thompson phil at riverbankcomputing.com
Tue Jan 22 09:04:04 GMT 2019


On 21 Jan 2019, at 11:13 pm, Matthias Kuhn <matthias at opengis.ch> wrote:
> 
> Hi Phil
> 
> On 1/18/19 2:13 PM, Phil Thompson wrote:
>> On 18 Jan 2019, at 12:48 pm, Matthias Kuhn <matthias at opengis.ch> wrote:
>>> Or does this mean that if the refcount for this Python object dropped to
>>> 0 the cache will be invalidated anyway (and the real issue here is, that
>>> the python object is still alive somewhere)?
>> It should be invalidated when the ref count reaches 0.
> 
> It seems to be doing that. But when an additional /Transfer/ annotation
> comes into play things start to go worse.
> 
> The following code snippet reproduces the issue:
> 
> https://issues.qgis.org/issues/20661#note-2
> 
> 
> The interesting bits are the (almost) last two lines of the loop
> 
> * pt_g.clone() is a /Factory/ method
> 
> * The QgsGeometry constructor has a /Transfer/ annotation on the
> parameter, if this one is not called, everything goes well.
> 
> 
> Here are the first couple of lines of the output:
> 
> ------------------------------------------
> 
> new pt  0x5d98240
> new pt  0x5f257c0
> new pt  0x4283da0
> new pt  0x5d98240
> WHAT??????!!!!!  0x5f257c0
> new pt  0x629fa60
> new pt  0x5d3c470
> WHAT??????!!!!!  0x5d98240
> new pt  0x2e2ac90
> new pt  0x4283da0
> new pt  0x5dcef50
> new pt  0x5f770d0
> new pt  0x629fa60
> WHAT??????!!!!!  0x5d98240
> 
> ------------------------------------------
> 
> 
> Any idea what the additional Transfer of the object triggers?

See the docs.

I can't really comment as you haven't explained the class hierachy or the use of annotations in the ctors.

Does the cloned object have a parent (in which case it's not a factory)?

Phil


More information about the PyQt mailing list