exception in tk callbacks?

F

Ferenc Engard

Hello,

Take the following example:

--------------------------------------
require 'tk.rb'
trap 0, proc { sleep 0.1 }

e=TkEntry.new()
e.validatecommand([proc{|w,t| valid(w,t)},'%W %V'])
e.validate('focusout')
e2=TkEntry.new()

e.pack
e2.pack

def valid(w,t)
puts "valid!"
raise "exception"
end

Tk.mainloop
--------------------------------------

(The trap cmd still needed with the latest debian unstable ruby -- ruby
1.8.0 (2003-10-05) [i386-linux]...) :-(

If I focus e, then take focus away, it prints "valid!" and raises an
exception, as I expect. BUT, after that, the valid() method never runs
on subsequent focus loses!

What is the problem?

Ferenc
 
N

Nathan Weston

This is a known bug, and I believe is fixed in a later (CVS?) version
of ruby-tk which is not yet available in debian. If you search this
newsgroup in google groups, there have been a couple of threads on the
problem. IIRC, there is some magic code you can put at the beginning
of your program that prevents this bug.

Alternatively, you can just download to the stable versions of ruby
(1.6.7) and libtk-ruby, which is what I have done for the moment.

I have also reported this as a bug against the debian package, so
hopefully it will be fixed someday.

Nathan
 
E

Engard Ferenc

This is a known bug, and I believe is fixed in a later (CVS?) version
of ruby-tk which is not yet available in debian. If you search this
newsgroup in google groups, there have been a couple of threads on the
problem. IIRC, there is some magic code you can put at the beginning
of your program that prevents this bug.

I follow this group since August, and this exception-and-tk-callback problem
was only reported by me so far. The google right now is down, and since that
this problem wasn't solved in debian-unstable. Cannot you remember what code
was that? Don't you mix it with another exception-related problem which is
solved by the trap line you can see below?

[...]
require 'tk.rb'
trap 0, proc { sleep 0.1 } [...]
If I focus e, then take focus away, it prints "valid!" and raises an
exception, as I expect. BUT, after that, the valid() method never runs
on subsequent focus loses!

BTW, IIRC the 1.6.8 version also had problems with exceptions in callbacks.
The version 1.6.7 is not included in Debian anymore, and my application
should run on another systems, not just on mine, with CVS-compiled ruby...
:-(((

Thanks,
Ferenc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,352
Latest member
DianeKulik

Latest Threads

Top