[Kde-bindings] smoke (non-q)object ownership proposal/question

Richard Dale richard.dale at telefonica.net
Wed Jul 21 15:34:55 UTC 2010


On Wednesday, July 14, 2010 05:17:52 pm Arno Rehn wrote:
> On Monday 12 July 2010 08:51:29 Petr Vanek wrote:
> > here is my initial draft of a question/proposal for smoke:
> > 
> > Meta Information in Smoke
> > 
> > [snip]
> > 
> > Is there any idea or plan to provide this kind of information in a
> > generic way in smoke (somehow in a per-library way) so that it could
> > be used by any client of the binding?
> > 
> > If not, from my not very deep knowledge of smoke, I was imagining that
> > the best way would be to provide a mechanism in smoke itself to track
> > ownership of objects and then to provide a way in smoke itself to
> > manage the ownership status of the object based on some simple rules
> > (i.e. QLayout::addItem() called on the object - object externally
> > owned, QLayout::removeItem() called on the object, object not
> > externally owned).
> 
> Yes, you could add such meta information to SMOKE - I don't know if this is
> the correct way to do it, though. It would require quite some amounts of
> manual work, just to flag all those methods as 'ownership-changing'.
We could use  the metadata from projects like PyQt/PyKDE or QtJambi with their 
permission - it is the same whichever bindings technology you are using. Maybe 
it would be nice if there was an 'official' Qt and KDE repository with the meta 
data as it isn't always described in the documentation.

> In QtRuby and Qyoto we use a global event filter to track
> QEvent::ChildAdded and QEvent::ChildRemoved events and handle ownership
> according to this. This only works for QObject derived-classes, of course,
> so it is a bit limited. For QGraphicsStuff you can track the virtual
> itemChanged() method and update ownership information accordingly.
I can't remember if QtRuby actually montors these events - it might be just 
Qyoto - I'd need to check to code. I'm not sure this would work with more that 
one language bindings runtime trying to trap the events.

Normally the QtRuby runtime can do it dynamically in the mark phase of garbage 
as long as there are suitable methods to determine ownership (not always in 
the Qt/KDE libs). That isn't possible for languages with reference counting 
garbage collection though.

> There are other cases where we simply can't track ownership that easily and
> which then needs some manual help. But I'm not sure if this should all be
> put into SMOKE, given that we have rather generic ways of tracking most of
> the ownership information.
I think it would certainly be nice to have the info in the smoke libs at some 
point, but I think it might be hard to implement in a generic language 
independent way.

-- Richard



More information about the Kde-bindings mailing list