[Kde-bindings] playground/bindings/kimono
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Thu Mar 22 14:48:05 UTC 2007
SVN commit 645404 by rdale:
* Move GCHandle leak fixes - now no leaks in tutorial t14
CCMAIL: kde-bindings at kde.org
M +28 -4 SmokeInvocation.cs
M +11 -9 handlers.cpp
M +9 -8 qyoto.cpp
--- trunk/playground/bindings/kimono/SmokeInvocation.cs #645403:645404
@@ -199,11 +199,23 @@
} else if (parameters[i].ParameterType == typeof(double)) {
args[i] = stackPtr[i].s_double;
} else if (parameters[i].ParameterType == typeof(string)) {
- if (stackPtr[0].s_class != IntPtr.Zero)
+ if (stackPtr[0].s_class != IntPtr.Zero) {
args[i] = (string) ((GCHandle) stackPtr[i].s_class).Target;
+#if DEBUG
+ DebugGCHandle.Free((GCHandle) stackPtr[i].s_class);
+#else
+ ((GCHandle) stackPtr[i].s_class).Free();
+#endif
+ }
} else {
- if (stackPtr[0].s_class != IntPtr.Zero)
+ if (stackPtr[0].s_class != IntPtr.Zero) {
args[i] = ((GCHandle) stackPtr[i].s_class).Target;
+#if DEBUG
+ DebugGCHandle.Free((GCHandle) stackPtr[i].s_class);
+#else
+ ((GCHandle) stackPtr[i].s_class).Free();
+#endif
+ }
}
}
@@ -306,11 +318,23 @@
} else if (parameters[i].ParameterType == typeof(double)) {
args[i] = stackPtr[i].s_double;
} else if (parameters[i].ParameterType == typeof(string)) {
- if (stackPtr[0].s_class != IntPtr.Zero)
+ if (stackPtr[0].s_class != IntPtr.Zero) {
args[i] = (string) ((GCHandle) stackPtr[i].s_class).Target;
+#if DEBUG
+ DebugGCHandle.Free((GCHandle) stackPtr[i].s_class);
+#else
+ ((GCHandle) stackPtr[i].s_class).Free();
+#endif
+ }
} else {
- if (stackPtr[0].s_class != IntPtr.Zero)
+ if (stackPtr[0].s_class != IntPtr.Zero) {
args[i] = ((GCHandle) stackPtr[i].s_class).Target;
+#if DEBUG
+ DebugGCHandle.Free((GCHandle) stackPtr[i].s_class);
+#else
+ ((GCHandle) stackPtr[i].s_class).Free();
+#endif
+ }
}
}
}
--- trunk/playground/bindings/kimono/handlers.cpp #645403:645404
@@ -849,14 +849,17 @@
}
static void marshall_charP(Marshall *m) {
- switch(m->action()) {
- case Marshall::FromObject:
- if (m->var().s_class == 0) {
- m->item().s_voidp = 0;
- } else {
- m->item().s_voidp = (*IntPtrToCharStar)(m->var().s_class);
- }
- break;
+ switch(m->action()) {
+ case Marshall::FromObject:
+ {
+ if (m->var().s_class == 0) {
+ m->item().s_voidp = 0;
+ } else {
+ m->item().s_voidp = (*IntPtrToCharStar)(m->var().s_class);
+ (*FreeGCHandle)(m->var().s_voidp);
+ }
+ break;
+ }
case Marshall::ToObject:
{
@@ -905,7 +908,6 @@
}
(*FreeGCHandle)(m->var().s_voidp);
-
}
break;
case Marshall::ToObject:
--- trunk/playground/bindings/kimono/qyoto.cpp #645403:645404
@@ -851,7 +851,6 @@
~InvokeSlot() {
delete[] _stack;
delete[] _sp;
- (*FreeGCHandle)(_obj);
}
};
@@ -990,13 +989,6 @@
signature += " const";
}
- if (do_debug & qtdb_virtual) {
- printf( "virtual %p->%s::%s called\n",
- ptr,
- smoke->classes[smoke->methods[method].classId].className,
- (const char *) signature );
- }
-
void * obj = getPointerObject(ptr);
smokeqyoto_object *o = value_obj_info(obj);
@@ -1014,6 +1006,7 @@
void** _o = (void**)args[3].s_voidp;
args[0].s_int = qt_metacall(obj, _c, _id, _o);
+ (*FreeGCHandle)(obj);
return true;
}
@@ -1023,6 +1016,14 @@
return false;
}
+ if (do_debug & qtdb_virtual) {
+ printf( "virtual %p->%s::%s called\n",
+ ptr,
+ smoke->classes[smoke->methods[method].classId].className,
+ (const char *) signature );
+ fflush(stdout);
+ }
+
VirtualMethodCall c(smoke, method, args, obj, overridenMethod);
c.next();
return true;
More information about the Kde-bindings
mailing list