[PyQt] sip: how to make a python instance owned by C++ without using a parent
Phil Thompson
phil at riverbankcomputing.com
Sun Aug 26 21:50:43 BST 2012
On Sun, 26 Aug 2012 21:11:50 +0200, Mathias.Born at gmx.de wrote:
> On 26.08.2012, 18:15:55 Phil Thompson wrote:
>> On Wed, 15 Aug 2012 11:55:47 +0200, Mathias.Born at gmx.de wrote:
>>> On 15.08.2012, 11:05:42 Phil Thompson wrote:
>>>> I could change sipTransferTo() to do this if the owner was Py_None.
At
>>>> the
>>>> moment this is undocumented behaviour. Would this be sufficient?
>>>
>>> I believe so.
>
>> Done in hg.
>
> Phil,
>
> First tests show that this works well. It's an important feature, but
> burried deeply in the documentation, well, actually sort of obscured.
>
> Function "sipConvertToType" is documented as:
>
> If transferObj is NULL then the ownership is unchanged. If it is Py_None
> then
> ownership is transferred to Python via a call to sipTransferBack().
> Otherwise ownership is transferred to C/C++ and obj associated with
> transferObj via a call to sipTransferTo().
>
> Function "sipTransferTo" tells us:
> ... If owner is Py_None then obj is given an extra reference which is
> removed when the C++ instance’s destructor is called. ...
>
>
> Since "sipTransferTo" is mentioned by the docs of "sipConvertToType",
who
> would guess that Py_None has such a different meaning?
>
> How about adding a corresponding hint to the documentation
> of "sipConvertToType"?
I'm not sure that adding documentation to something about what it doesn't
do makes anything clearer.
Phil
More information about the PyQt
mailing list