Bug 100123

Summary: require 'Korundum' conflicts with require 'Qt'
Product: [Developer tools] bindings Reporter: Caleb Tennis <caleb>
Component: generalAssignee: kde-bindings
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Caleb Tennis 2005-02-23 22:06:50 UTC
Version:            (using KDE KDE 3.3.2)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3 
OS:                Linux

I can successfully use either require 'Korundum' or require 'Qt' in a program. However, if you use them in this order:

require 'Korundum'
require 'Qt'

You get the following error:

NameError: uninitialized constant KDE::CmdLineArgs
        from /usr/lib/ruby/site_ruby/1.8/KDE/korundum.rb:326:in `const_missing'
        from /usr/lib/ruby/site_ruby/1.8/KDE/korundum.rb:326


An obvious workaround is to not have both, but the error message isn't intuitive as to what the problem is.
Comment 1 Caleb Tennis 2005-02-23 22:07:28 UTC
Ugh.  Reverse the order above.  That is:

require 'Qt'
require 'Korundum'

is where the problem lies.
Comment 2 Richard Dale 2005-02-23 22:26:35 UTC
On Wednesday 23 February 2005 22:07, Caleb Tennis wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=100123
>
>
>
>
> ------- Additional Comments From caleb gentoo org  2005-02-23 22:07 -------
> Ugh.  Reverse the order above.  That is:
>
> require 'Qt'
> require 'Korundum'
>
> is where the problem lies.
You shouldn't use both require statements - I think this is more a 
documentation problem rather than a bug.

-- Richard

Comment 3 Caleb Tennis 2005-02-24 01:17:49 UTC
What do you think about adding a check in Korundum?  Something like:

$".include? "Qt/qtruby.rb" and raise "require 'Korundum' must not follow require 'Qt'"
Comment 4 Richard Dale 2005-02-24 10:10:33 UTC
On Thursday 24 February 2005 01:17, Caleb Tennis wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=100123
>
>
>
>
> ------- Additional Comments From caleb gentoo org  2005-02-24 01:17 -------
> What do you think about adding a check in Korundum?  Something like:
>
> $".include? "Qt/qtruby.rb" and raise "require 'Korundum' must not follow
> require 'Qt'" _______________________________________________
Yes ok, I can't see that doing any harm. But it'll have to wait until the cvs 
is unfrozen for the kde 3.4 release though.

-- Richard

Comment 5 Richard Dale 2005-05-29 13:04:01 UTC
SVN commit 419405 by rdale:

* At the moment require 'Qt' and require 'Korundum' statements can't appear
  in the same ruby program. Suitable fatal error messages are now displayed
  to indicate the cause of the problem. Fixes bug reported by Caleb Tennis
  and Dave M
CCMAIL: caleb@gentoo.org
CCMAIL: dave.m@email.it
CCBUGS: 100123


 M  +7 -0      korundum/ChangeLog  
 M  +6 -1      korundum/rubylib/korundum/Korundum.cpp  
 M  +11 -3     qtruby/rubylib/qtruby/Qt.cpp  


--- trunk/KDE/kdebindings/korundum/ChangeLog #419404:419405
@@ -1,3 +1,10 @@
+2005-05-29  Richard Dale  <Richard_Dale@tipitina.demon.co.uk>
+
+	* At the moment require 'Qt' and require 'Korundum' statements can't appear
+	  in the same ruby program. Suitable fatal error messages are now displayed
+	  to indicate the cause of the problem. Fixes bug reported by Caleb Tennis
+	  and Dave M
+
 2005-05-21  Richard Dale  <Richard_Dale@tipitina.demon.co.uk>
 
 	* KDE::DCOPRef.methods now returns remote DCOP methods as well as the local methods in
--- trunk/KDE/kdebindings/korundum/rubylib/korundum/Korundum.cpp #419404:419405
@@ -1171,6 +1171,11 @@
 void
 Init_korundum()
 {
+	if (qt_internal_module != Qnil) {
+		rb_fatal("require 'Korundum' must not follow require 'Qt'\n");
+		return;
+	}
+
 	set_new_kde(new_kde);
 #if KDE_VERSION >= 0x030200
 	set_kconfigskeletonitem_immutable(kconfigskeletonitem_immutable);
@@ -1179,7 +1184,7 @@
 		
 	// The Qt extension is linked against libsmokeqt.so, but Korundum links against
 	// libsmokekde.so only. Specifying both a 'require Qt' and a 'require Korundum',
-	// would give a link error.
+	// would give a link error (see the rb_fatal() error above).
 	// So call the Init_qtruby() initialization function explicitely, not via 'require Qt'
 	// (Qt.o is linked into libqtruby.so, as well as the Qt.so extension).
 	Init_qtruby();
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #419404:419405
@@ -101,7 +101,7 @@
 VALUE kconfigskeleton_itemenum_choice_class = Qnil;
 VALUE kio_udsatom_class = Qnil;
 VALUE kwin_class = Qnil;
-bool application_terminated = FALSE;
+bool application_terminated = false;
 };
 
 #define logger logger_backend
@@ -2582,12 +2582,20 @@
 void
 Init_qtruby()
 {
+	if (qt_Smoke != 0L) {
+		// This function must have been called twice because both
+		// 'require Qt' and 'require Korundum' statements have
+		// been included in a ruby program
+		rb_fatal("require 'Qt' must not follow require 'Korundum'\n");
+		return;
+	}
+
     init_qt_Smoke();
     qt_Smoke->binding = new QtRubySmokeBinding(qt_Smoke);
     install_handlers(Qt_handlers);
 
-    methcache.setAutoDelete(1);
-    classcache.setAutoDelete(1);
+    methcache.setAutoDelete(true);
+    classcache.setAutoDelete(true);
 
 	if (qt_module == Qnil) {
 		qt_module = rb_define_module("Qt");
Comment 6 Caleb Tennis 2006-05-05 20:47:12 UTC
this one is fixed