[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] References returned from C++
From:       "Arve Knudsen" <arve.knudsen () gmail ! com>
Date:       2008-06-23 11:19:48
Message-ID: a0d6258d0806230419p1930f421w3c3ed5a2a3961987 () mail ! gmail ! com
[Download RAW message or body]

On 6/22/08, Phil Thompson <phil@riverbankcomputing.com> wrote:
> On Sun, 22 Jun 2008 12:53:41 +0200, "Arve Knudsen" <arve.knudsen@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.
>
>  For example...
>
>     const Status &status = foo->status();
>
>     while (!status.finished)
>         foo->process();
>
>  ...with the planned change a directly translated Python version would no
>  longer work. Instead you would have to move the call to status() to be
>  inside the loop...
>
>     while not foo.status().finished:
>         foo.process()
>
>  While I don't think there is anything in PyQt that would be affected by
>  this, SIP is used for much more than just PyQt.

Thanks Phil, this sounds like a really useful addition to SIP.

Arve
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic