From: Takaaki T. <tt...@kt...> - 2001-11-25 15:20:29
|
Hello, I should inform you that I've renamed the module 'Fltk' with 'FLTK', and made 'Fltk' an alias to 'FLTK'. Now I think we will use 'FLTK' officially since 'Fltk' doesn't appear at FLTK's web pages and documentations. I hope you to agree with me. Regards, -- Takaaki Tateishi <tt...@kt...> |
From: Kent D. <ke...@st...> - 2001-11-26 21:52:19
|
Hi. As I'm trying to implement the "Simple Text Editor" sample in Ruby-Fltk, (or should that be Ruby-FLTK now? ;-) I found out that the Fl::paste wasn't wrapped. So I gave it a naive try, which works, but seg-faults if Fltk.paste( widget ) is called outside when Fltk.run is running... I'm guessing that this is due to something in FLTK, and I wonder if there is any to check to see that the Fltk.run is running? (See below about Fl::check and Fl::ready) <CVSDIFF> [kentda@v128a ruby-fltk]$ cvs diff ? test/fl_func.rb cvs server: Diffing . Index: fltk.cc =================================================================== RCS file: /cvsroot/ruby-fltk/ruby-fltk/fltk.cc,v retrieving revision 1.65 diff -r1.65 fltk.cc 849a850,865 > /** > * the Fl::paste(Fl_Widget*) method > */ > static VALUE rb_fltk_paste( VALUE self, VALUE widget ){ > Fl_Widget *reciever = NULL; > reciever = rb_to_fl(widget); > if(reciever) { > Fl::paste( *reciever ); > }else{ > rb_raise(rb_eArgError, "Need widget to send paste-event to."); > } > return Qnil; > } > > > 972a989 > DEF_MODULE_FUNC(paste,1); </CVSDIFF> Some testcode <CODE> require 'rubyfltk.so' w = Fltk::Window.new(0,0,200,200) b = Fltk::Button.new(0,0,20,20,"X"){|a,b| Fltk.paste(w) } w.show #Fltk.paste( b) # this crashes Fltk.run # here, pushing the button which calls Fltk.paste(w) goes ok. #Fltk.paste( b ) # this crashes too. </CODE> After writing the above, I did try using Fl::check(), but I'm not sure that is a safe bet, since the Fl::ready() documentation talks about callbacks maybe being illegal, and Fl::ready() returns values that don't seem to mean quite the same. The seg-faults disappear if I add this test to the rb_fltk_paste implementation before Fl::paste... <CODE> if(!Fl::check()) rb_raise(rb_eSystemCallError, "FLTK does not appear to be taking events!"); </CODE> I hope my code isn't totally embarrasing :-) -- <[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]> )____(stud.techn.;ind.øk.data)||(softwareDeveloper.at(Trustix))_( /"Opinions expressed are mine and not those of my Employer, "\ ( "the University, my girlfriend, stray cats, banana fruitflies, " ) \"nor the frontal lobe of my left cerebral hemisphere. "/ |
From: Takaaki T. <tt...@kt...> - 2001-11-26 23:59:59
|
At Mon, 26 Nov 2001 23:03:53 -0500, Kent Dahl <ke...@st...> wrote: > require 'rubyfltk.so' > w = Fltk::Window.new(0,0,200,200) > b = Fltk::Button.new(0,0,20,20,"X"){|a,b| > Fltk.paste(w) # (*1) > } > w.show > #Fltk.paste( b) # this crashes (*2) > Fltk.run # here, pushing the button which calls Fltk.paste(w) goes ok. > #Fltk.paste( b ) # this crashes too. (*3) > </CODE> Though I also tried, (*2) didn't crash and (*3) crashed. I think b must be destroied when calling Fl::run(), but Ruby/FLTK treats it as alive widget. I've fixed this problem. Would you try again? -- Takaaki Tateishi <tt...@kt...> |
From: Kent D. <ke...@st...> - 2001-11-27 07:44:06
|
Takaaki Tateishi wrote: > Though I also tried, (*2) didn't crash and (*3) crashed. > I think b must be destroied when calling Fl::run(), but > Ruby/FLTK treats it as alive widget. > I've fixed this problem. Would you try again? I may have mixed up the w and b in the example, as I was trying many permutations. Sorry about that. Here is the new test code I am using. <CODE> require 'rubyfltk.so' w = Fltk::Window.new(0,0,200,200) b = Fltk::Button.new(0,0,20,20,"X"){|a,b| #w.hide puts "hidden" Fltk.paste(w) #(*1) puts "done" } #Fltk.paste( nil ) #(*2) #Fltk.paste( w ) #(*3) w.show Fltk.paste( w ) #(*4) Fltk.run Fltk.paste( w ) #(*5) </CODE> *2 and *3 still seg-fault. *2 is because rb_to_fl returns NULL if VALUE is Qnil, which I don't think Fl::paste likes. *3 is the main problem I worry about. It seems that w.show in turn initializes something that allows events to be sent. I tried to call b.show and then Fltk.paste(b), but that still segfaults. So I still suspect some FLTK wide initialization code, which may be that Fl::check() is responcible to... uhm, check? (I removed my code and cvs updated when I tried this.) -- <[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]> )____(stud.techn.;ind.øk.data)||(softwareDeveloper.at(Trustix))_( /"Opinions expressed are mine and not those of my Employer, "\ ( "the University, my girlfriend, stray cats, banana fruitflies, " ) \"nor the frontal lobe of my left cerebral hemisphere. "/ |
From: Takaaki T. <tt...@kt...> - 2001-11-27 09:59:45
|
At Tue, 27 Nov 2001 08:55:42 -0500, Kent Dahl <ke...@st...> wrote: > *2 and *3 still seg-fault. > *2 is because rb_to_fl returns NULL if VALUE is Qnil, which I don't > think Fl::paste likes. Sorry, that's my fault. > *3 is the main problem I worry about. It seems that w.show in turn > initializes something that allows events to be sent. I tried to call > b.show and then Fltk.paste(b), but that still segfaults. So I still > suspect some FLTK wide initialization code, which may be that > Fl::check() is responcible to... uhm, check? I can see about *3. I made the rb_fltk_paste() call Fl::check() before Fl::paste(). By the way, where did you call b.show and Fltk.paste(b)? Thanks, -- Takaaki Tateishi <tt...@kt...> |