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

List:       kde-devel
Subject:    Re: Python wrapper
From:       Phil Thompson <phil () river-bank ! demon ! co ! uk>
Date:       1999-04-18 14:21:57
[Download RAW message or body]

weis@stud.uni-frankfurt.de wrote:
> 
> Hi,
> 
> On Sun, 18 Apr 1999, Phil Thompson wrote:

> > What's impossible to be sure of is that the object the pointer points to
> > is still there.  The bindings do a lot to try and detect if an object's
> > dtor has been called - but you can't guarantee it.
> 
> I can :-) First I map pointers to ints with a QIntDict and QPtrDict.
> Python only sees int -> nobody can send me crazy pointers.
> I check the type with QObject::inherits.
> 
> I install a watchdog for every object that I passed to python once.
> the watchdoc connects to the QObject destroyed signal. if I get this
> signal I remove the objects from my dicts. if python stull wants to
> talk about this object then I can see that it is no longer in
> my dict and raise an error.
> 
> A bit complicated and perhaps no optimal performance but it is secure.

Good idea (I think I'll steal it) - but it only works for classes
derived from QObject, which is fine if that's all you're trying to
wrap.  I can think of situations (which may not exist in the Qt/KDE
libraries) where a Python object has a pointer that is no longer valid.

Phil

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

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