[Kde-bindings] Qyoto: showstopper bug - help needed

Arno Rehn arno at arnorehn.de
Sat Jun 16 18:36:10 UTC 2012


On 16/06/12 20:21, Dimitar Dobrev wrote:
> Hi, Steven,
>
> Thanks for your reply. I've fixed part of the problem: 3 missing breaks in the giant switch for QEvents (see my changes from today). However, invalid casts still occur in other places like this ExpandedTo method.
>
> I'm not completely sure if what you point to is a bug or not. Basically, mapPointer is not a cache as I initially thought but a mapping between an unmanaged and a managed object. This is why I wrote that when that line was commented out calls to a single property returned different managed objects. So, unmapPointer removes the managed object when the unmanaged one is destroyed (you can see for yourself where unmapPointer is used). However, I think that no objects must be unmapped in the marshallers but then I'm not sure why FreeGCHandle is necessary. Arno, could you please shed some light on this?
FreeGCHandle() calls are necessary in nearly every method that deal with 
C# objects. The GCHandles used count as hard references to the objects - 
so when the native code is done with the managed instance, it has to 
release the hard ref again.
This is completely unrelated to the pointer mapping (which uses weak 
refs only).

unmapPointer should only be called when a wrapped instance is actually 
deleted, which should normally not be the case in any marshaller.
On the other hand however, a wrapper can create new objects which then 
need to be mapPointer()'ed.

-- 
Arno Rehn




More information about the Kde-bindings mailing list