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

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Nov 12 14:33:52 UTC 2009


SVN commit 1047984 by rdale:

    * Applied a patch from Davor Ocelic. Here's an overview of the changes:


        ruby/qtruby/src/handlers.cpp:

        Added { "unsigned char*", marshall_ucharP } so that conversion
        from String to "unsigned char*" would work. Qt code doesn't
        have unsigned char*, but Smoke seems to internally convert
        uchar* to unsigned char*.


        ruby/qtruby/src/Qt.cpp:

        The code at the place of patch checks whether a method is overriden
        in Ruby. But during GC, it's not allowed to execute Ruby code anyway,
        so the patch removes this check altogether. (In rare, but existing
        situations, this check itself lead to new object allocation, crashing
        the application).

        (New info: the function we've used to check if it's running during
        GC or not seems to be Ruby 1.9 specific, so a simple compatibility
        for 1.8 should be added before committing).


        ruby/qtruby/src/lib/Qt/qtruby4.rb

        1) Added GC.disable around line of code that says: "@block = block".
        This makes a difference between being and being not able to run
        with GC.stress= true. Reason unclear, comments appreciated.

        2) Extended typename =~ /^(?:u?char\*)$/ checks to support 
        unsigned char.

        3) Skip "def instance_exec" if it is already defined
        (it is in Ruby 1.9)

    * Thanks to Davor for the patch

CCMAIL: kde-bindings at kde.org


 M  +37 -0     ChangeLog  
 M  +2 -1      src/Qt.cpp  
 M  +1 -0      src/handlers.cpp  
 M  +7 -3      src/lib/Qt/qtruby4.rb  


--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #1047983:1047984
@@ -3,7 +3,44 @@
     * The Qt::SizePolicy.horizontalStretch= method wasn't working with a Smoke
       library created with the new generator as the type 'unsigned char' wasn't
       recognized. Thanks to Stefano Crocco for reporting the bug.
+    * Applied a patch from Davor Ocelic. Here's an overview of the changes:
 
+
+        ruby/qtruby/src/handlers.cpp:
+
+        Added { "unsigned char*", marshall_ucharP } so that conversion
+        from String to "unsigned char*" would work. Qt code doesn't
+        have unsigned char*, but Smoke seems to internally convert
+        uchar* to unsigned char*.
+
+
+        ruby/qtruby/src/Qt.cpp:
+
+        The code at the place of patch checks whether a method is overriden
+        in Ruby. But during GC, it's not allowed to execute Ruby code anyway,
+        so the patch removes this check altogether. (In rare, but existing
+        situations, this check itself lead to new object allocation, crashing
+        the application).
+
+        (New info: the function we've used to check if it's running during
+        GC or not seems to be Ruby 1.9 specific, so a simple compatibility
+        for 1.8 should be added before committing).
+
+
+        ruby/qtruby/src/lib/Qt/qtruby4.rb
+
+        1) Added GC.disable around line of code that says: "@block = block".
+        This makes a difference between being and being not able to run
+        with GC.stress= true. Reason unclear, comments appreciated.
+
+        2) Extended typename =~ /^(?:u?char\*)$/ checks to support 
+        unsigned char.
+
+        3) Skip "def instance_exec" if it is already defined
+        (it is in Ruby 1.9)
+
+    * Thanks to Davor for the patch
+
 2009-08-19  Richard Dale  <richard.j.dale at gmail.com>
     * Added a patch from Youhei Kondou to make the is_a? and kind_of? methods
       use the C++ class ancestors obtained from the smoke libary
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #1047983:1047984
@@ -269,7 +269,8 @@
 		methodName += (sizeof("operator") - 1);
 	}
 		// If the virtual method hasn't been overriden, just call the C++ one.
-	if (rb_respond_to(obj, rb_intern(methodName)) == 0) {
+		// During GC, avoid checking for override and just call the C++ version
+	if (rb_during_gc() || rb_respond_to(obj, rb_intern(methodName)) == 0) {
     	return false;
 	}
 	QtRuby::VirtualMethodCall c(smoke, method, args, obj, ALLOCA_N(VALUE, smoke->methods[method].numArgs));
--- trunk/KDE/kdebindings/ruby/qtruby/src/handlers.cpp #1047983:1047984
@@ -2516,6 +2516,7 @@
     { "QwtArray<int>&", marshall_QVectorint },
     { "signed int&", marshall_it<int *> },
     { "uchar*", marshall_ucharP },
+    { "unsigned char*", marshall_ucharP },
     { "unsigned long long int", marshall_it<long long> },
     { "unsigned long long int&", marshall_it<long long> },
     { "void", marshall_void },
--- trunk/KDE/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #1047983:1047984
@@ -2361,7 +2361,11 @@
 			if metaObject.indexOfSlot(signature) == -1
 				self.class.slots signature
 			end
+			# This makes a difference between being and not being able
+			# to run with GC.stress= true. Reason unclear.
+			gc_disabled= GC.disable
 			@block = block
+			GC.enable unless gc_disabled
 		end
 
 		def invoke(*args)
@@ -2515,9 +2519,9 @@
 			elsif argtype == 's'
 				if typename =~ /^(const )?((QChar)[*&]?)$/
 					return 3
-				elsif typename =~ /^(?:u?char\*)$/
+				elsif typename =~ /^(?:(u(nsigned )?)?char\*)$/
 					return 2
-				elsif typename =~ /^(?:const u?char\*)$/
+				elsif typename =~ /^(?:const (u(nsigned )?)?char\*)$/
 					return 1
 				elsif typename =~ /^(?:(?:const )?(QString)[*&]?)$/
 					return 4
@@ -3047,7 +3051,7 @@
 	# matter for the intended use in invoking blocks as Qt slots.
 	def instance_exec(*arguments, &block)
 		block.bind(self)[*arguments]
-	end
+	end unless defined? instance_exec
 end
 
 class Proc 



More information about the Kde-bindings mailing list