mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* additional check of Tk interpreters' status for a little more safety
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2555db608e
commit
b873f41c1e
4 changed files with 32 additions and 13 deletions
|
@ -1020,7 +1020,7 @@ ip_invoke_real(argc, argv, obj)
|
||||||
|
|
||||||
/* exception on mainloop */
|
/* exception on mainloop */
|
||||||
if (ptr->return_value == TCL_ERROR) {
|
if (ptr->return_value == TCL_ERROR) {
|
||||||
if (event_loop_abort_on_exc > 0) {
|
if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
|
||||||
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
||||||
} else {
|
} else {
|
||||||
if (event_loop_abort_on_exc < 0) {
|
if (event_loop_abort_on_exc < 0) {
|
||||||
|
|
|
@ -3359,7 +3359,7 @@ class TkObject<TkKernel
|
||||||
private :tk_trace_variable
|
private :tk_trace_variable
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if defined? @var_id
|
# tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3721,10 +3721,21 @@ class TkWindow<TkObject
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def _destroy_children
|
||||||
|
children = []
|
||||||
|
rexp = /^#{self.path}\.[^.]+$/
|
||||||
|
TkCore::INTERP.tk_windows.each{|path, obj|
|
||||||
|
children << obj if path =~ rexp
|
||||||
|
}
|
||||||
|
children.each{|obj| obj.destroy}
|
||||||
|
end
|
||||||
|
private :_destroy_children
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
super
|
super
|
||||||
|
_destroy_children
|
||||||
tk_call 'destroy', epath
|
tk_call 'destroy', epath
|
||||||
if @cmdtbl
|
if defined?(@cmdtbl)
|
||||||
for id in @cmdtbl
|
for id in @cmdtbl
|
||||||
uninstall_cmd id
|
uninstall_cmd id
|
||||||
end
|
end
|
||||||
|
@ -4959,6 +4970,10 @@ module TkComposite
|
||||||
@path = @epath = @frame.path
|
@path = @epath = @frame.path
|
||||||
initialize_composite(*args)
|
initialize_composite(*args)
|
||||||
end
|
end
|
||||||
|
unless defined? @delegates
|
||||||
|
@delegates = {}
|
||||||
|
@delegates['DEFAULT'] = @frame
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def epath
|
def epath
|
||||||
|
@ -4969,10 +4984,6 @@ module TkComposite
|
||||||
private :initialize_composite
|
private :initialize_composite
|
||||||
|
|
||||||
def delegate(option, *wins)
|
def delegate(option, *wins)
|
||||||
unless @delegates
|
|
||||||
@delegates = {}
|
|
||||||
@delegates['DEFAULT'] = @frame
|
|
||||||
end
|
|
||||||
if @delegates[option].kind_of?(Array)
|
if @delegates[option].kind_of?(Array)
|
||||||
for i in wins
|
for i in wins
|
||||||
@delegates[option].push(i)
|
@delegates[option].push(i)
|
||||||
|
@ -5077,7 +5088,13 @@ end
|
||||||
# widget_destroy_hook
|
# widget_destroy_hook
|
||||||
require 'tkvirtevent'
|
require 'tkvirtevent'
|
||||||
TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|widget|
|
TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|widget|
|
||||||
if widget.respond_to? :__destroy_hook__
|
if widget.respond_to?(:path)
|
||||||
|
w = widget.path
|
||||||
|
else
|
||||||
|
w = widget.to_s
|
||||||
|
end
|
||||||
|
if widget.respond_to?(:__destroy_hook__) &&
|
||||||
|
TkCore::INTERP._invoke('winfo','exist',w) == '1'
|
||||||
begin
|
begin
|
||||||
widget.__destroy_hook__
|
widget.__destroy_hook__
|
||||||
rescue Exception
|
rescue Exception
|
||||||
|
|
|
@ -34,7 +34,7 @@ class TkTimer
|
||||||
begin
|
begin
|
||||||
ex_obj.cb_call
|
ex_obj.cb_call
|
||||||
rescue Exception
|
rescue Exception
|
||||||
Tk_CBTBL[obj_id] = nil
|
ex_obj.cancel
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -143,6 +143,7 @@ class TkTimer
|
||||||
set_procs(*args) if args != []
|
set_procs(*args) if args != []
|
||||||
|
|
||||||
@running = false
|
@running = false
|
||||||
|
@in_callback = false
|
||||||
end
|
end
|
||||||
|
|
||||||
attr :after_id
|
attr :after_id
|
||||||
|
|
|
@ -44,10 +44,10 @@ cmd = Proc.new{|txt|
|
||||||
}
|
}
|
||||||
|
|
||||||
# call on the default master interpreter
|
# call on the default master interpreter
|
||||||
trusted_slave.eval_proc(cmd, 'trusted')
|
trusted_slave.eval_proc(cmd, 'trusted') # label -> .w00012
|
||||||
safe_slave1.eval_proc(cmd, 'safe1')
|
safe_slave1.eval_proc(cmd, 'safe1') # label -> .w00015
|
||||||
safe_slave2.eval_proc(cmd, 'safe2')
|
safe_slave2.eval_proc(cmd, 'safe2') # label -> .w00018
|
||||||
cmd.call('master')
|
cmd.call('master') # label -> .w00021
|
||||||
|
|
||||||
TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start
|
TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start
|
||||||
TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start
|
TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start
|
||||||
|
@ -57,6 +57,7 @@ TkTimer.new(10000, 1,
|
||||||
proc{
|
proc{
|
||||||
trusted_slave.eval_proc{Tk.root.destroy}
|
trusted_slave.eval_proc{Tk.root.destroy}
|
||||||
trusted_slave.delete
|
trusted_slave.delete
|
||||||
|
print "*** The trusted_slave is deleted by the timer.\n"
|
||||||
}).start
|
}).start
|
||||||
|
|
||||||
Tk.mainloop
|
Tk.mainloop
|
||||||
|
|
Loading…
Reference in a new issue