[Kde-bindings] playground/bindings/kimono

Arno Rehn kde at arnorehn.de
Thu Feb 8 19:24:18 UTC 2007


SVN commit 631688 by arnorehn:

* Made destructors work. The only problem was that we have to check
  if the instance of which a method should be invoked still exists.
  This was not the case, e.g. if the QApplication instance was destroyed
  at the end of an app and with it all other Qt instances.
  Now the DeleteQApp-Hack isn't needed anymore, too.

CCMAIL: kde-bindings at kde.org



 M  +8 -0      ChangeLog  
 M  +2 -2      SmokeInvocation.cs  
 M  +3 -3      gui/QApplication.cs  
 M  +13 -1     qyoto.cpp  


--- trunk/playground/bindings/kimono/ChangeLog #631687:631688
@@ -1,3 +1,11 @@
+2007-02-08  Arno Rehn  <arno at arnorehn.de>
+
+	* Made destructors work. The only problem was that we have to check
+	  if the instance of which a method should be invoked still exists.
+	  This was not the case, e.g. if the QApplication instance was destroyed
+	  at the end of an app and with it all other Qt instances.
+	  Now the DeleteQApp-Hack isn't needed anymore, too.
+
 2007-02-08  Richard Dale  <rdale at foton.es>
 
 	* Added a first attempt at setting up the strongReferenceMap and calling
--- trunk/playground/bindings/kimono/SmokeInvocation.cs #631687:631688
@@ -376,7 +376,7 @@
 
 			// Ignore destructors where the destructor method isn't the actual class
 			// of the instance
-			if (	(	((SmokeMethod) smokeMethod[0]).MungedName.StartsWith("~")
+			/*if (	(	((SmokeMethod) smokeMethod[0]).MungedName.StartsWith("~")
 						&& (("~" + _className) != ((SmokeMethod) smokeMethod[0]).MungedName) )
 					|| ((SmokeMethod) smokeMethod[0]).MungedName == "~QMetaObject" )
 			{
@@ -392,7 +392,7 @@
 				return returnMessage;
 			} else {
 				;
-			}
+			}*/
 
 			if (methodId == -1) {
 				Console.Error.WriteLine(	"LEAVE Invoke() ** Missing method ** {0}.{1}", 
--- trunk/playground/bindings/kimono/gui/QApplication.cs #631687:631688
@@ -514,9 +514,9 @@
 			return StaticQApplication().KeyboardInputDirection();
 		}
 		public static new int Exec() {
-			int ret = StaticQApplication().Exec();
-			Qyoto.DeleteQApp();
-			return ret;
+			/*int ret = StaticQApplication().Exec();
+			Qyoto.DeleteQApp();*/
+			return StaticQApplication().Exec();
 		}
 		public static void SetQuitOnLastWindowClosed(bool quit) {
 			StaticQApplication().SetQuitOnLastWindowClosed(quit);
--- trunk/playground/bindings/kimono/qyoto.cpp #631687:631688
@@ -521,6 +521,7 @@
     int _items;
     Smoke::StackItem * _retval;
     bool _called;
+    bool _ctor;
 public:
     MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items) :
 	_cur(-1), _smoke(smoke), _method(method), _target(target), _current_object(0), _sp(sp), _items(items), _called(false)
@@ -537,6 +538,17 @@
 		_items = _smoke->methods[_method].numArgs;
 		_stack = new Smoke::StackItem[items + 1];
 		_retval = _sp;
+		
+		Smoke::Method _tmp = _smoke->methods[_method];
+		// constructor?
+		_ctor = (strcmp(_smoke->methodNames[_tmp.name], _smoke->className(_tmp.classId)) == 0);
+		
+		// We have to check here, if our target does still exist
+		// 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
+		if ((getPointerObject(_current_object) == 0) && !_ctor && !(_tmp.flags == Smoke::mf_static))
+			_called = true;
     }
 
 	~MethodCall() {
@@ -593,7 +605,7 @@
 		MethodReturnValue r(_smoke, _method, _stack, _retval);
 
 		// A constructor
-		if (strcmp(_smoke->methodNames[method().name], _smoke->className(method().classId)) == 0) {
+		if (_ctor) {
 			smokeqyoto_object  * o = alloc_smokeqyoto_object(true, _smoke, method().classId, _stack[0].s_voidp);
 			(*SetSmokeObject)(_target, o);
 		    mapPointer(_target, o, o->classId, 0);



More information about the Kde-bindings mailing list