[Kde-bindings] kdebindings/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Oct 11 08:04:16 UTC 2004


CVS commit by rdale: 


* Added a global flag 'application_terminated'. Once this is set the QtRuby runtime will no longer 
delete any C++ instances. This will hopefully fix crash on application exit problems reported  
by Thibauld Favre. 

CCMAIL: kde-bindings at kde.org 


  M +8 -0      ChangeLog   1.127
  M +9 -0      rubylib/qtruby/Qt.cpp   1.95
  M +2 -1      rubylib/qtruby/handlers.cpp   1.73
  M +1 -0      rubylib/qtruby/lib/Qt/qtruby.rb   1.40


--- kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb  #1.39:1.40
@@ -130,4 +130,5 @@
                         widgets.each {|widget| widget.dispose}
                         self.dispose
+                        Qt::Internal.application_terminated = true
                 end
         end

--- kdebindings/qtruby/rubylib/qtruby/handlers.cpp  #1.72:1.73
@@ -51,4 +51,5 @@ extern "C" {
 extern VALUE set_obj_info(const char * className, smokeruby_object * o);
 extern VALUE qt_internal_module;
+extern bool application_terminated;
 };
 
@@ -145,5 +146,5 @@ smokeruby_free(void * p)
         if(do_debug & qtdb_gc) printf("Checking for delete (%s*)%p allocated: %s\n", className, o->ptr, o->allocated ? "true" : "false");
     
-        if(!o->allocated || o->ptr == 0) {
+        if(application_terminated || !o->allocated || o->ptr == 0) {
                 free(o);
                 return;

--- kdebindings/qtruby/rubylib/qtruby/Qt.cpp  #1.94:1.95
@@ -92,4 +92,5 @@ VALUE qt_internal_module = Qnil;
 VALUE qt_base_class = Qnil;
 VALUE qt_qmetaobject_class = Qnil;
+bool application_terminated = FALSE;
 };
 
@@ -2042,4 +2043,11 @@ set_new_kde(VALUE (*new_kde) (int, VALUE
 }
 
+static VALUE
+set_application_terminated(VALUE /*self*/, VALUE yn)
+{
+    application_terminated = (yn == Qtrue ? true : false);
+        return Qnil;
+}
+
 void
 Init_qtruby()
@@ -2146,4 +2154,5 @@ Init_qtruby()
     rb_define_method(qt_internal_module, "qtruby_version", (VALUE (*) (...)) qtruby_version, 0);
     rb_define_method(qt_internal_module, "cast_object_to", (VALUE (*) (...)) cast_object_to, 2);
+    rb_define_method(qt_internal_module, "application_terminated=", (VALUE (*) (...)) set_application_terminated, 1);
 
         rb_include_module(qt_module, qt_internal_module);

--- kdebindings/qtruby/ChangeLog  #1.126:1.127
@@ -1,2 +1,10 @@
+2004-10-11  Richard Dale  <Richard_Dale at tipitina.demon.co.uk>
+
+ * Added a global flag 'application_terminated'. Once this is set the QtRuby runtime will no longer
+   delete any C++ instances. This will hopefully fix crash on application exit problems reported 
+   by Thibauld Favre.
+
+ CCMAIL: kde-bindings at kde.org
+
 2004-10-10  Richard Dale  <Richard_Dale at tipitina.demon.co.uk>
 





More information about the Kde-bindings mailing list