mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
2d24928b42
commit
1dd762d181
2 changed files with 28 additions and 20 deletions
|
@ -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>
|
Thu Nov 27 16:58:48 2003 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* win32/win32.c (rb_w32_stat): remove _fullpath() for NUL: device.
|
* win32/win32.c (rb_w32_stat): remove _fullpath() for NUL: device.
|
||||||
|
|
|
@ -30,13 +30,7 @@ class TkTimer
|
||||||
@after_id = nil
|
@after_id = nil
|
||||||
ex_obj = Tk_CBTBL[obj_id]
|
ex_obj = Tk_CBTBL[obj_id]
|
||||||
return "" if ex_obj == nil; # canceled
|
return "" if ex_obj == nil; # canceled
|
||||||
#_get_eval_string(ex_obj.do_callback)
|
ex_obj.cb_call
|
||||||
begin
|
|
||||||
ex_obj.cb_call
|
|
||||||
rescue Exception
|
|
||||||
ex_obj.cancel
|
|
||||||
""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.info
|
def self.info
|
||||||
|
@ -53,12 +47,13 @@ class TkTimer
|
||||||
@in_callback = true
|
@in_callback = true
|
||||||
begin
|
begin
|
||||||
@return_value = @current_proc.call(self)
|
@return_value = @current_proc.call(self)
|
||||||
rescue Exception
|
rescue Exception => e
|
||||||
if @cancel_on_exception
|
if @cancel_on_exception
|
||||||
cancel
|
cancel
|
||||||
return nil
|
@return_value = e
|
||||||
|
return e
|
||||||
else
|
else
|
||||||
fail $!
|
fail e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @set_next
|
if @set_next
|
||||||
|
@ -118,14 +113,7 @@ class TkTimer
|
||||||
|
|
||||||
@wait_var = TkVariable.new(0)
|
@wait_var = TkVariable.new(0)
|
||||||
|
|
||||||
# @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
|
@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
|
|
||||||
})
|
|
||||||
|
|
||||||
@set_next = true
|
@set_next = true
|
||||||
|
|
||||||
|
@ -186,6 +174,7 @@ class TkTimer
|
||||||
|
|
||||||
def cancel_on_exception=(mode)
|
def cancel_on_exception=(mode)
|
||||||
@cancel_on_exception = mode
|
@cancel_on_exception = mode
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def running?
|
def running?
|
||||||
|
@ -198,6 +187,7 @@ class TkTimer
|
||||||
|
|
||||||
def loop_rest=(rest)
|
def loop_rest=(rest)
|
||||||
@do_loop = rest
|
@do_loop = rest
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_procs(interval, loop_exec, *procs)
|
def set_procs(interval, loop_exec, *procs)
|
||||||
|
@ -388,9 +378,21 @@ class TkTimer
|
||||||
if $SAFE >= 4
|
if $SAFE >= 4
|
||||||
fail SecurityError, "can't wait timer at $SAFE >= 4"
|
fail SecurityError, "can't wait timer at $SAFE >= 4"
|
||||||
end
|
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)
|
@wait_var.wait(on_thread, check_root)
|
||||||
self
|
if @return_value.kind_of?(Exception)
|
||||||
|
fail @return_value
|
||||||
|
else
|
||||||
|
@return_value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def eventloop_wait(check_root = false)
|
def eventloop_wait(check_root = false)
|
||||||
wait(false, check_root)
|
wait(false, check_root)
|
||||||
|
|
Loading…
Add table
Reference in a new issue