diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-05 22:37:55 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-05 22:37:55 +0000 |
commit | 3c1a077f65ea4759c2efd51ff2290e56df4af72f (patch) | |
tree | 4ac6c42bec73e41a74796954ca2753529f899d39 | |
parent | dd0f22f9cbf592d3ae17b03708ab66b4be7e6640 (diff) |
merges a part of r31717 and a part of r31742.
Fixes a problem in Tk.mainloop.
--
* ext/tk/lib/tk.rb: hang-up at exit before calling Tk.mainloop.
--
* ext/tk/lib/tk.rb: fail to start Tk.mainloop (exit immediately) on
some environment (reported on [ruby-talk:381444]).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 44 | ||||
-rw-r--r-- | version.h | 8 |
3 files changed, 51 insertions, 10 deletions
@@ -1,3 +1,12 @@ +Fri May 27 08:35:04 2011 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> + + * ext/tk/lib/tk.rb: hang-up at exit before calling Tk.mainloop. + +Tue May 24 07:06:34 2011 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> + + * ext/tk/lib/tk.rb: fail to start Tk.mainloop (exit immediately) on + some environment (reported on [ruby-talk:381444]). + Sat Jan 22 11:49:55 2011 Aaron Patterson <aaron@tenderlovemaking.com> * ext/psych/lib/psych/visitors/to_ruby.rb: fixing merge key support diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 4beaaf932a..87ed2a449e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1236,6 +1236,9 @@ module TkCore raise e end + interp.mainloop_abort_on_exception = true + Thread.current.instance_variable_set("@interp", interp) + status = [nil] def status.value self[0] @@ -1271,26 +1274,32 @@ proc __startup_rbtk_mainloop__ {args} { } set __initial_state_of_rubytk__ 1 trace add variable __initial_state_of_rubytk__ unset __startup_rbtk_mainloop__ + +# complete initializing +ruby {TkCore::INTERP_THREAD[:interp] = TkCore::INTERP_THREAD.instance_variable_get('@interp')} EOS begin begin #TclTkLib.mainloop_abort_on_exception = false + #interp.mainloop_abort_on_exception = true + #Thread.current[:interp] = interp #Thread.current[:status].value = TclTkLib.mainloop(true) - interp.mainloop_abort_on_exception = true - Thread.current[:interp] = interp Thread.current[:status].value = interp.mainloop(true) rescue SystemExit=>e Thread.current[:status].value = e rescue Exception=>e Thread.current[:status].value = e + p e if $DEBUG retry if interp.has_mainwindow? ensure INTERP_MUTEX.synchronize{ INTERP_ROOT_CHECK.broadcast } end - #Thread.current[:status].value = TclTkLib.mainloop(false) - Thread.current[:status].value = interp.mainloop(false) + unless interp.deleted? + #Thread.current[:status].value = TclTkLib.mainloop(false) + Thread.current[:status].value = interp.mainloop(false) + end ensure # interp must be deleted before the thread for interp is dead. @@ -1300,12 +1309,20 @@ EOS end } + # check a Tcl/Tk interpreter is initialized until INTERP_THREAD[:interp] - Thread.pass + # Thread.pass + INTERP_THREAD.run end + # INTERP_THREAD.run raise INTERP_THREAD[:interp] if INTERP_THREAD[:interp].kind_of? Exception + # check an eventloop is running + while INTERP_THREAD.alive? && TclTkLib.mainloop_thread?.nil? + INTERP_THREAD.run + end + INTERP = INTERP_THREAD[:interp] INTERP_THREAD_STATUS = INTERP_THREAD[:status] @@ -1316,6 +1333,9 @@ EOS INTERP_THREAD.kill end } + + # (for safety's sake) force the eventloop to run + INTERP_THREAD.run end def INTERP.__getip @@ -1845,6 +1865,11 @@ EOS begin TclTkLib.set_eventloop_window_mode(true) + + # force run the eventloop + TkCore::INTERP._eval_without_enc('update') + TkCore::INTERP._eval_without_enc('catch {set __initial_state_of_rubytk__}') + INTERP_THREAD.run if check_root INTERP_MUTEX.synchronize{ INTERP_ROOT_CHECK.wait(INTERP_MUTEX) @@ -1855,8 +1880,15 @@ EOS end } else - INTERP_THREAD.value + # INTERP_THREAD.value + begin + INTERP_THREAD.value + rescue Exception => e + raise e + end end + rescue Exception => e + raise e ensure TclTkLib.set_eventloop_window_mode(false) end @@ -1,13 +1,13 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 271 +#define RUBY_PATCHLEVEL 272 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2011 -#define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 31 -#define RUBY_RELEASE_DATE "2011-05-31" +#define RUBY_RELEASE_MONTH 6 +#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DATE "2011-06-06" #include "ruby/version.h" |