[Kde-bindings] playground/bindings/kimono

Arno Rehn kde at arnorehn.de
Sat Feb 10 15:13:46 UTC 2007


SVN commit 632296 by arnorehn:

* If the aboutToQuit() signal is catched, no destructors will be called.
  Replaces the check for qApp == 0. No warning about QSocketNotifiers at
  the end of the main event loop anymore.

CCMAIL: kde-bindings at kde.org



 M  +6 -0      ChangeLog  
 M  +22 -4     qyoto.cpp  


--- trunk/playground/bindings/kimono/ChangeLog #632295:632296
@@ -1,3 +1,9 @@
+2007-02-10  Arno Rehn  <arno at arnorehn.de>
+
+	* If the aboutToQuit() signal is catched, no destructors will be called.
+	  Replaces the check for qApp == 0. No warning about QSocketNotifiers at
+	  the end of the main event loop anymore.
+
 2007-02-10  Richard Dale  <rdale at foton.es>
 
 	* Improved debug messages in SmokeInvocation.cs
--- trunk/playground/bindings/kimono/qyoto.cpp #632295:632296
@@ -29,7 +29,7 @@
 #include <QtCore/qstringlist.h>
 #include <QMetaMethod>
 
-#include <QtGui/qmainwindow.h>
+#include <QtTest/qsignalspy.h>
 
 #undef DEBUG
 #ifndef __USE_POSIX
@@ -83,6 +83,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);
 };
@@ -549,10 +552,10 @@
 		// 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 was just destroyed and we want to call a destructor.
+		// 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 ( ((getPointerObject(_current_object) == 0) && !_ctor && !(_tmp.flags & Smoke::mf_static))
-			|| ((_tmp.flags & Smoke::mf_dtor) && (qApp == 0)) )
+		if ( ((_tmp.flags & Smoke::mf_dtor) && qapp_spy && (qapp_spy->count() != 0))
+			|| ((getPointerObject(_current_object) == 0) && !_ctor && !(_tmp.flags & Smoke::mf_static)) )
 			_called = true;
     }
 
@@ -614,6 +617,13 @@
 			smokeqyoto_object  * 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()));
+			}
 		}
 
     }
@@ -869,6 +879,14 @@
 		}
 		unmapPointer(o, o->classId, 0);
 		o->ptr = 0;
+		
+		// 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*/) {



More information about the Kde-bindings mailing list