diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-30 04:36:29 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-30 04:36:29 +0000 |
commit | b873f41c1e577168b6322bd96f38b077b44d5314 (patch) | |
tree | 5824d094039c3c2af7e448bb3946f1be10dbabe0 /ext/tk/lib/tk.rb | |
parent | 2555db608ec305fdd478c48b6e689715e711b037 (diff) |
* 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
Diffstat (limited to 'ext/tk/lib/tk.rb')
-rw-r--r-- | ext/tk/lib/tk.rb | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 6ee5c36fba..13e41ece44 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -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 |