[Kde-bindings] playground/bindings/kimono
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Feb 13 05:07:28 UTC 2007
SVN commit 633076 by rdale:
* Removed the signal spy check and replaced it with a global flag
'application_terminated'. Once the flag is set, destructors are no
longer called.
CCMAIL: kde-bindings at kde.org
M +6 -0 ChangeLog
M +3 -0 Qyoto.cs
M +5 -8 SmokeInvocation.cs
M +3 -1 core/QCoreApplication.cs
M +3 -1 gui/QApplication.cs
M +8 -34 qyoto.cpp
--- trunk/playground/bindings/kimono/ChangeLog #633075:633076
@@ -1,3 +1,9 @@
+2007-02-13 Richard Dale <rdale at foton.es>
+
+ * Removed the signal spy check and replaced it with a global flag
+ 'application_terminated'. Once the flag is set, destructors are no
+ longer called.
+
2007-02-12 Richard Dale <rdale at foton.es>
* The scheme for caching the smoke methodId inside a SmokeMethod Attribute
--- trunk/playground/bindings/kimono/Qyoto.cs #633075:633076
@@ -51,6 +51,9 @@
public static extern void Init_qyoto();
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+ public static extern void SetApplicationTerminated();
+
+ [DllImport("libqyoto", CharSet=CharSet.Ansi)]
static extern IntPtr make_metaObject(IntPtr parent, IntPtr stringdata, int stringdataCount,
IntPtr data, int dataCount);
--- trunk/playground/bindings/kimono/SmokeInvocation.cs #633075:633076
@@ -403,10 +403,6 @@
unsafe {
stack[i+1].s_class = (IntPtr) 0;
}
- } else if (types[i] == typeof(int) || types[i].IsEnum) {
- stack[i+1].s_int = (int) callMessage.Args[i];
- } else if (!types[i].IsPrimitive) {
- stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
} else if (types[i] == typeof(bool)) {
stack[i+1].s_bool = (bool) callMessage.Args[i];
} else if (types[i] == typeof(sbyte)) {
@@ -417,6 +413,8 @@
stack[i+1].s_short = (short) callMessage.Args[i];
} else if (types[i] == typeof(ushort)) {
stack[i+1].s_ushort = (ushort) callMessage.Args[i];
+ } else if (types[i] == typeof(int) || types[i].IsEnum) {
+ stack[i+1].s_int = (int) callMessage.Args[i];
} else if (types[i] == typeof(uint)) {
stack[i+1].s_uint = (uint) callMessage.Args[i];
} else if (types[i] == typeof(long)) {
@@ -427,11 +425,10 @@
stack[i+1].s_float = (float) callMessage.Args[i];
} else if (types[i] == typeof(double)) {
stack[i+1].s_double = (double) callMessage.Args[i];
+ } else if (types[i] == typeof(string)) {
+ stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
} else {
- Console.Error.WriteLine( "MethodName: {0}.{1} Unknown type: {2}",
- _className,
- callMessage.MethodName,
- types[i] );
+ stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
}
}
}
--- trunk/playground/bindings/kimono/core/QCoreApplication.cs #633075:633076
@@ -187,7 +187,9 @@
return StaticQCoreApplication().Instance();
}
public static int Exec() {
- return StaticQCoreApplication().Exec();
+ int result = StaticQCoreApplication().Exec();
+ Qyoto.SetApplicationTerminated();
+ return result;
}
public static void ProcessEvents(uint flags) {
StaticQCoreApplication().ProcessEvents(flags);
--- trunk/playground/bindings/kimono/gui/QApplication.cs #633075:633076
@@ -514,7 +514,9 @@
return StaticQApplication().KeyboardInputDirection();
}
public static new int Exec() {
- return StaticQApplication().Exec();
+ int result = StaticQApplication().Exec();
+ Qyoto.SetApplicationTerminated();
+ return result;
}
public static void SetQuitOnLastWindowClosed(bool quit) {
StaticQApplication().SetQuitOnLastWindowClosed(quit);
--- trunk/playground/bindings/kimono/qyoto.cpp #633075:633076
@@ -29,8 +29,6 @@
#include <QtCore/qstringlist.h>
#include <QMetaMethod>
-#include <QtTest/qsignalspy.h>
-
#undef DEBUG
#ifndef __USE_POSIX
#define __USE_POSIX
@@ -83,11 +81,9 @@
extern bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
extern bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
-// watches out for the aboutToQuit() signal from qApp
-QSignalSpy* qapp_spy;
-
extern "C" {
extern void * set_obj_info(const char * className, smokeqyoto_object * o);
+bool application_terminated = false;
};
extern void smokeStackToQtStack(Smoke::Stack stack, void ** o, int items, MocArgument* args);
@@ -533,7 +529,7 @@
_o = value_obj_info(_target);
if (_o != 0 && _o->ptr != 0) {
if ( isDestructor()
- && (!_o->allocated || IsContainedInstance(_o)) )
+ && (!_o->allocated || IsContainedInstance(_o) || application_terminated) )
{
_called = true;
_o->allocated = false;
@@ -547,19 +543,6 @@
_items = _smoke->methods[_method].numArgs;
_stack = new Smoke::StackItem[items + 1];
_retval = _sp;
-
- // We have to check here, if our target does still exists.
- // If there is no entry in the weakRef Dictionary, the instance doesn't exist anymore.
- // There's also no entry, if the method is a constructor or the method is static.
- // If the target doesn't exist anymore, set _called to true so the method won't be invoked.
- // The other possibility is that the qApp is about to quit and we want to call a destructor.
- // This could lead to a crash when we interfere with the destroying mechanism of Q(Core)Application.
-// if ( ((_tmp.flags & Smoke::mf_dtor) && qapp_spy && (qapp_spy->count() != 0))
-// || ((getPointerObject(_current_object) == 0) && !_ctor && !(_tmp.flags & Smoke::mf_static)) )
-// _called = true;
- if (qapp_spy != 0 && qapp_spy->count() != 0) {
- _called = true;
- }
}
~MethodCall() {
@@ -626,13 +609,6 @@
_o = alloc_smokeqyoto_object(true, _smoke, method().classId, _stack[0].s_voidp);
(*SetSmokeObject)(_target, _o);
mapPointer(_target, _o, _o->classId, 0);
-
- // create a signal spy to catch the "aboutToQuit()" signal
- if (strcmp("QApplication", _smoke->className(method().classId)) == 0
- || strcmp("QCoreApplication", _smoke->className(method().classId)) == 0) {
-
- qapp_spy = new QSignalSpy(qApp, SIGNAL(aboutToQuit()));
- }
} else if (isDestructor()) {
unmapPointer(_o, _o->classId, 0);
(*SetSmokeObject)(_target, 0);
@@ -893,14 +869,6 @@
unmapPointer(o, o->classId, 0);
(*SetSmokeObject)(obj, 0);
free_smokeqyoto_object(o);
-
- // delete the previously created QSignalSpy
- if (strcmp("QApplication", smoke->className(classId)) == 0
- || strcmp("QCoreApplication", smoke->className(classId)) == 0) {
-
- delete qapp_spy;
- qapp_spy = 0;
- }
}
bool callMethod(Smoke::Index method, void *ptr, Smoke::Stack args, bool /*isAbstract*/) {
@@ -1264,6 +1232,12 @@
}
void
+SetApplicationTerminated()
+{
+ application_terminated = true;
+}
+
+void
CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items)
{
#ifdef DEBUG
More information about the Kde-bindings
mailing list