* 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:
nagai 2003-07-30 04:36:29 +00:00
Родитель 2555db608e
Коммит b873f41c1e
4 изменённых файлов: 32 добавлений и 13 удалений

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

@ -1020,7 +1020,7 @@ ip_invoke_real(argc, argv, obj)
/* exception on mainloop */
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);
} else {
if (event_loop_abort_on_exc < 0) {

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

@ -3359,7 +3359,7 @@ class TkObject<TkKernel
private :tk_trace_variable
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
@ -3721,10 +3721,21 @@ class TkWindow<TkObject
self
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
super
_destroy_children
tk_call 'destroy', epath
if @cmdtbl
if defined?(@cmdtbl)
for id in @cmdtbl
uninstall_cmd id
end
@ -4959,6 +4970,10 @@ module TkComposite
@path = @epath = @frame.path
initialize_composite(*args)
end
unless defined? @delegates
@delegates = {}
@delegates['DEFAULT'] = @frame
end
end
def epath
@ -4969,10 +4984,6 @@ module TkComposite
private :initialize_composite
def delegate(option, *wins)
unless @delegates
@delegates = {}
@delegates['DEFAULT'] = @frame
end
if @delegates[option].kind_of?(Array)
for i in wins
@delegates[option].push(i)
@ -5077,7 +5088,13 @@ end
# widget_destroy_hook
require 'tkvirtevent'
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
widget.__destroy_hook__
rescue Exception

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

@ -34,7 +34,7 @@ class TkTimer
begin
ex_obj.cb_call
rescue Exception
Tk_CBTBL[obj_id] = nil
ex_obj.cancel
""
end
end
@ -143,6 +143,7 @@ class TkTimer
set_procs(*args) if args != []
@running = false
@in_callback = false
end
attr :after_id

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

@ -44,10 +44,10 @@ cmd = Proc.new{|txt|
}
# call on the default master interpreter
trusted_slave.eval_proc(cmd, 'trusted')
safe_slave1.eval_proc(cmd, 'safe1')
safe_slave2.eval_proc(cmd, 'safe2')
cmd.call('master')
trusted_slave.eval_proc(cmd, 'trusted') # label -> .w00012
safe_slave1.eval_proc(cmd, 'safe1') # label -> .w00015
safe_slave2.eval_proc(cmd, 'safe2') # label -> .w00018
cmd.call('master') # label -> .w00021
TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start
TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start
@ -57,6 +57,7 @@ TkTimer.new(10000, 1,
proc{
trusted_slave.eval_proc{Tk.root.destroy}
trusted_slave.delete
print "*** The trusted_slave is deleted by the timer.\n"
}).start
Tk.mainloop