[PyQt] References returned from C++

Phil Thompson phil at riverbankcomputing.com
Sun Jun 22 14:50:22 BST 2008


On Sun, 22 Jun 2008 14:12:45 +0200, Giovanni Bajo <rasky at develer.com>
wrote:
> On Sun, 2008-06-22 at 12:41 +0100, Phil Thompson wrote:
>> On Sun, 22 Jun 2008 12:53:41 +0200, "Arve Knudsen"
> <arve.knudsen at gmail.com>
>> wrote:
>> > How does one normally treat references returned by SIP-wrapped C++
>> > objects? I just determined a segmentation fault in my program resulted
>> > from an object first being obtained as a reference (in the C++ sense)
>> > from a C++ method, and then destroyed with the parent object. Does one
>> > normally keep in mind that the object dies implicitly with its C++
>> > parent, or is there a way to have SIP give you copies rather than
>> > borrowed references?
>> 
>> I will probably change SIP to make a copy when the reference is const. I
>> think this fixes most of the problem areas although it does introduce an
>> incompatibility.
> 
> Maybe there could be an annotation to control this behaviour? I think
> both approaches are equally good, so the best solution is probably to
> make the SIP user choose.

Definitely. The decision is whether to make the modified behaviour the
default.

Phil



More information about the PyQt mailing list