diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-31 07:59:18 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-31 07:59:18 +0000 |
commit | 7126624b4effe49919e35224054cc48e86716f39 (patch) | |
tree | 081a374af97921e6315428db1bf7d58cbda40955 /ext/tk/lib/multi-tk.rb | |
parent | 89769459ba6ab5987ac257f35e2559726437e35b (diff) | |
download | ruby-7126624b4effe49919e35224054cc48e86716f39.tar.gz |
* wrap the command-proc of TkScale : pass the numeric object to the proc
* better support for widgets created on Tk interpreter (without Ruby)
* a little more stable on Multiple Tk interpreters running
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/multi-tk.rb')
-rw-r--r-- | ext/tk/lib/multi-tk.rb | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 438c3c0816..99c25f2595 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -6,6 +6,13 @@ require 'tcltklib' require 'thread' ################################################ +# ignore exception on the mainloop + +# TclTkLib.mainloop_abort_on_exception = false +TclTkLib.mainloop_abort_on_exception = nil + + +################################################ # exceptiopn to treat the return value from IP class MultiTkIp_OK < Exception def self.send(thred, ret=nil) @@ -22,17 +29,11 @@ class MultiTkIp_OK < Exception end MultiTkIp_OK.freeze + ################################################ # methods for construction class MultiTkIp - - # ignore exception on the mainloop - #TclTkLib.mainloop_abort_on_exception = false - TclTkLib.mainloop_abort_on_exception = nil - - ###################################### - - SLAVE_IP_ID = ['slave'.freeze, '00000'] + SLAVE_IP_ID = ['slave'.freeze, '0'] @@IP_TABLE = {} @@ -827,6 +828,32 @@ end # depend on TclTkIp class MultiTkIp + def mainloop(check_root = true, restart_on_dead = true) + unless restart_on_dead + @interp.mainloop(check_root) + else + begin + loop do + @interp.mainloop(check_root) + if check_root + begin + break if @interp._invoke('winfo', 'exists?', '.') == "1" + rescue Exception + break + end + end + end + rescue StandardError + if TclTkLib.mainloop_abort_on_exception != nil + STDERR.print("warning: Tk mainloop on ", @interp.inspect, + " receives ", $!.class.inspect, + " exception (ignore) : ", $!.message, "\n"); + end + retry + end + end + end + def make_safe @interp.make_safe end |