How to write handwritten code to access the C++ object when the corresponding python object destroyed?

Weitian Leung <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CADp56LY=E0ciRa3mxgxng-9xJwxN11GBmJrTfL-w4reE5bz_TA@mail.gmail.com>
Hi,
    I'm noob in SIP. Say I have two abstract interfaces and one method to
create the object:

struct IUnknown /Abstract/
> {
>     virtual void AddRef() = 0;
>     virtual void Release() = 0;
>
>     %GCClearCode
>         printf("GCClearCode\n");
>     %End
> };
>
> struct IDemo : public IUnknown /Abstract/
> {
>     virtual void SayHi() = 0;
> };
>

void createDemo(IDemo **demo /Out/);
>


Using in python side:
idemo = demo.createDemo()
idemo = None

Is it possible to write some handwritten code that call the Release method
when idemo set to None or when  idemo doing GC?
Or if we can call AddRef automatically when idemo assign to another object.

I known that on python side we can call AddRef/Release to make it works,
but I want the code more python's way.

The %GCClearCode handwritten code never called in this case.
And the %GCTraverseCode handwritten code only call when the object make an
assignment to other object.
Am I missing something?

Please check the full code in the  attached file.

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
demo.zip (application/zip, 1 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.