[PyKDE] Re: How do I fix this?
ian reinhart geiser
geiseri at yahoo.com
Sat Feb 16 21:27:33 GMT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 16 February 2002 05:16 am, Phil Thompson wrote about [PyKDE] Re:
How do I fix this?:
> ian reinhart geiser wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Greetings
> > I have a situation where I am wrapping a class that handles its instances
> > internally Basicly when i create a new object as follows:
> > myObject(parent, name)
> >
> > The parent manages the instance and the instance is kept in the parents
> > internal lookup table. The problem is at the end of the function python
> > cleans the myObject instance up. Is there a way to keep python from
> > killing these objects, but still allow me to delete them from C++?
>
> Use the /TransferThis/ option on the parent argument. Look at the .sip
> file for any PyQt class that is derived from QObject.
>
> The result is that the generated code transfers ownership (ie.
> responsibility for calling the dtor) for the new instance to the parent
> object (so long as the parent object is non-zero).
Ah now I have another problem. It seems when I delete the parent there is a
race condition between python removeing my object for me and my memory
cleanup. About 75% of the time python wins and I get QObject double object
deletion warning, but on the 25% of the time that python loses the object is
deleted and python has a conniption. Is there a way to force python to just
deal, and assume I know what i am doing? I have seen talk of this before
about adding a PY_XINCREF in your sip file for the constructor of the object
and a PY_XDECREF of the destructor. Is this correct?
Thanks
-ian reinhart geiser
- --
:-- Ian Reinhart Geiser --:
GPG Key: D6A6 7E16 13A9 B5A7 9E18 D1A7 3F2E B64D 19BC 76F8
===========================================================
===========================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8bsCdPy62TRm8dvgRAu3pAKDCDsKvD9Oyw2TTY0d9laF/tpxMQACfSoM/
/kQeScUHQYOn5Hbj+x5Q48c=
=Hy5Z
-----END PGP SIGNATURE-----
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
More information about the PyQt
mailing list