[Kde-bindings] playground/bindings/kimono

Phil Thompson phil at riverbankcomputing.co.uk
Thu Feb 8 13:34:20 UTC 2007


On Thursday 08 February 2007 12:02 pm, Richard Dale wrote:
> On Thursday 08 February 2007, Phil Thompson wrote:
> > On Thursday 08 February 2007 11:17 am, Richard Dale wrote:
> > > SVN commit 631534 by rdale:
> > >
> > > * Added a strongReferenceMap to hold a mapping from a C++ pointer to
> > >   a C# instance. It is used to prevent garbage collection for instances
> > >   which are contained in another instance, such as a QObject with a
> > >   parent, even when there are no references to the child within the C#
> > >   Qyoto application code. When the parent finally deletes the child on
> > >   the C++ side, the reference is removed from the Dictionary by the
> > >   SmokeMarshallers.UnmapPointer() method.
> >
> > There are other places where this can happen - not just with QObject
> > parent/child relationships. There are also methods where the reverse
> > happens. You could look at the PyQt .sip files to see all the places
> > where it needs to be considered - just grep for '/Transfer'.
>
> Thanks for the suggestion, I've had a look and there are a lot of methods
> annotated with Transfer. In QtRuby the garbage collection works differently
> - a function is called in the mark phase of garbage collection, and in that
> it has to tranverse the children of any container instance. So it doesn't
> need to monitor every method that might change the status of the children,
> and just needs to know which are container classes and how to find the
> children.
>
> So I could just pull out all the Transfer methods from PyQt, and put them
> into a table used when generating the code for the C# Qyoto sources, and
> add a suitable annotation on the method calls that could be queried at
> runtime to determine whether a strong reference should be created or
> removed.

You'll need to annotate the arguments to the method calls as well. See the SIP 
documentation for an explanation of the different Transfer annotations.

Phil



More information about the Kde-bindings mailing list