[PyQt] KeepReference in constructors for wrapped instances

Giovanni Bajo rasky at develer.com
Tue Feb 15 13:13:42 GMT 2011


Hi Phil,

given the following (pseudo) sip file:

===================================================
class Manager
{ ... };

class User
{
public:
     User(Manager * /KeepReference=0/);
     void changeManager(Manager * /KeepReference=0/);
}
===================================================

it looks like the internal sip_api_keep_reference is not called when
passing through the constructor. Not only the generated .cpp file does
not have an explicit call to sipKeepReference() in the constructor
(whilst it calls it for the changeManager method), but even stepping
through code in the argument-parsing function I couldn't see any calls
to sip_api_keep_reference.

I also checked PyQt, but it looks like /KeepReference/ in constructors
is only used for classes like QLatin1String, for a "const char*"
argument, which is special-cased in the argument-parsing code with
letter 'A'. I could not find any usage of KeepReference for wrapped
instances in PyQt constructors, probably because the Qt ownership system
is a superset of its functionality.

The documentation does not mention anything specific about KeepReference
in constructors.

Is it a bug in SIP?

BTW I'm using SIP 4.10, though I checked the changelog and the Mercurial
history and I could only find minimal changes in the keep reference
code.

Thanks!
-- 
Giovanni Bajo   ::  rasky at develer.com
Develer S.r.l.  ::  http://www.develer.com

My Blog: http://giovanni.bajo.it
Last post: Compile-time Function Execution in D



More information about the PyQt mailing list