[Kde-bindings] KDE/kdebindings/ruby/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Jul 18 16:48:03 UTC 2008


SVN commit 834324 by rdale:

* Fixed the Qt::Application constructor so that it can subclassed. Thanks
  to Stefano Crocco for reporting the bug

CCMAIL: kde-bindings at kde.org
CCMAIL: stefano.crocco at alice.it


 M  +5 -0      ChangeLog  
 M  +8 -0      src/lib/Qt/qtruby4.rb  
 M  +0 -21     src/qtruby.cpp  


--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #834323:834324
@@ -1,3 +1,8 @@
+2008-07-18  Richard Dale  <richard.j.dale at gmail.com>
+
+	* Fixed the Qt::Application constructor so that it can subclassed. Thanks
+	  to Stefano Crocco for reporting the bug
+
 2008-07-13  Cyrille Berger  <cberger at cberger.net>
   * Reverting kross2smoke to use a pointer, since that what kross use for now.
 
--- trunk/KDE/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #834323:834324
@@ -244,6 +244,14 @@
 	end
 
 	class Application < Qt::Base
+		def initialize(*args)
+			if args.length == 1 && args[0].kind_of?(Array)
+				super(args.length + 1, [$0] + args[0])
+			else
+				super(*args)
+			end
+            $qApp = self
+		end 
 		# Delete the underlying C++ instance after exec returns
 		# Otherwise, rb_gc_call_finalizer_at_exit() can delete
 		# stuff that Qt::Application still needs for its cleanup.
--- trunk/KDE/kdebindings/ruby/qtruby/src/qtruby.cpp #834323:834324
@@ -1007,27 +1007,7 @@
 	return result;
 }
 
-static VALUE
-new_qapplication(int argc, VALUE * argv, VALUE klass)
-{
- 	VALUE result = Qnil;
 
-	if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {
-		// Convert '(ARGV)' to '(NUM, [$0]+ARGV)'
-		VALUE * local_argv = ALLOCA_N(VALUE, argc + 1);
-		VALUE temp = rb_ary_dup(argv[0]);
-		rb_ary_unshift(temp, rb_gv_get("$0"));
-		local_argv[0] = INT2NUM(RARRAY(temp)->len);
-		local_argv[1] = temp;
-		result = new_qt(2, local_argv, klass);
-	} else {
-		result = new_qt(argc, argv, klass);
-	}
-
-	rb_gv_set("$qApp", result);
-	return result;
-}
-
 // Returns $qApp.ARGV() - the original ARGV array with Qt command line options removed
 static VALUE
 qapplication_argv(VALUE /*self*/)
@@ -1771,7 +1751,6 @@
 	}
 	
 	if (packageName == "Qt::Application" || packageName == "Qt::CoreApplication" ) {
-		rb_define_singleton_method(klass, "new", (VALUE (*) (...)) new_qapplication, -1);
 		rb_define_method(klass, "ARGV", (VALUE (*) (...)) qapplication_argv, 0);
 	} else if (packageName == "Qt::Object") {
 		rb_define_singleton_method(klass, "staticMetaObject", (VALUE (*) (...)) qobject_staticmetaobject, 0);



More information about the Kde-bindings mailing list