* ext/tk/lib/tkafter.rb: bug fix on TkTimer#cancel_on_exception=(mode).

TkTimer#wait recieves the exception of the callback.
  The exception is kept on @return_value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2003-11-27 08:39:33 +00:00
Родитель 2d24928b42
Коммит 1dd762d181
2 изменённых файлов: 28 добавлений и 20 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Thu Nov 27 17:36:42 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkafter.rb: bug fix on TkTimer#cancel_on_exception=(mode).
TkTimer#wait recieves the exception of the callback.
The exception is kept on @return_value.
Thu Nov 27 16:58:48 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.c (rb_w32_stat): remove _fullpath() for NUL: device.

Просмотреть файл

@ -30,13 +30,7 @@ class TkTimer
@after_id = nil
ex_obj = Tk_CBTBL[obj_id]
return "" if ex_obj == nil; # canceled
#_get_eval_string(ex_obj.do_callback)
begin
ex_obj.cb_call
rescue Exception
ex_obj.cancel
""
end
ex_obj.cb_call
end
def self.info
@ -53,12 +47,13 @@ class TkTimer
@in_callback = true
begin
@return_value = @current_proc.call(self)
rescue Exception
rescue Exception => e
if @cancel_on_exception
cancel
return nil
@return_value = e
return e
else
fail $!
fail e
end
end
if @set_next
@ -118,14 +113,7 @@ class TkTimer
@wait_var = TkVariable.new(0)
# @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
@cb_cmd = TkCore::INTERP.get_cb_entry(proc{
begin
self.do_callback
rescue
self.cancel
end
})
@cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
@set_next = true
@ -186,6 +174,7 @@ class TkTimer
def cancel_on_exception=(mode)
@cancel_on_exception = mode
self
end
def running?
@ -198,6 +187,7 @@ class TkTimer
def loop_rest=(rest)
@do_loop = rest
self
end
def set_procs(interval, loop_exec, *procs)
@ -388,9 +378,21 @@ class TkTimer
if $SAFE >= 4
fail SecurityError, "can't wait timer at $SAFE >= 4"
end
return self unless @running
unless @running
if @return_value.kind_of?(Exception)
fail @return_value
else
return @return_value
end
end
@wait_var.wait(on_thread, check_root)
self
if @return_value.kind_of?(Exception)
fail @return_value
else
@return_value
end
end
def eventloop_wait(check_root = false)
wait(false, check_root)