I upgraded to FreeBSD's latest version of ruby.
ruby -v
ruby 1.8.1 (2004-05-02) [i386-freebsd5]
Now, some of my Ruby/Tk applications won't work anymore.
The problem seems to be this.
cmd = proc{
puts "a"
Thread.new{
sleep 10
}
puts "b"
}
TkButton.new{
text "Push"
command cmd
pack
}
When running cmd.call i get the printout "a" and "b" quickly. The new Thread
is just sleeping quietly in the background.
However, when I push my TkButton, I get the "a", then the whole program
sleeps for 10 seconds, then I get the "b". So something is really strange
here. I had no problems with the code above in earlier versions.
Thank you very much for your patch.
Now it works nicely.
···
-----Original Message-----
From: Hidetoshi NAGAI [mailto:nagai@ai.kyutech.ac.jp]
Sent: Friday, June 04, 2004 3:20 AM
To: ruby-talk ML
Subject: Re: TkButton#command problem with threads
Hi,
From: "Henrik Steensland" <henst374@student.liu.se>
Subject: TkButton#command problem with threads
Date: Fri, 4 Jun 2004 08:17:27 +0900
Message-ID: <20040603231722.679E921B19@arcadia.unit.liu.se>
> When running cmd.call i get the printout "a" and "b"
quickly. The new
> Thread is just sleeping quietly in the background.
> However, when I push my TkButton, I get the "a", then the whole
> program sleeps for 10 seconds, then I get the "b". So something is
> really strange here. I had no problems with the code above
in earlier versions.
Thank you for your report. Please test the following patch.
>
--- tcltklib.c.old 2004-06-04 10:15:14.000000000 +0900
+++ tcltklib.c 2004-06-04 10:16:17.000000000 +0900
@@ -1008,7 +1008,9 @@
(VALUE)0);
#else
+ rb_thread_critical = Qfalse;
ret = rb_eval_string_protect(arg->string, &status);
+ rb_thread_critical = Qtrue;
if (status) {
char *errtype, *buf;
int errtype_len, len;
@@ -1288,9 +1290,13 @@
struct cmd_body_arg *arg;
{
VALUE ret;
+ int thr_crit_bup;
DUMP1("call ip_ruby_cmd_core");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qfalse;
ret = rb_apply(arg->receiver, arg->method, arg->args);
+ rb_thread_critical = thr_crit_bup;
DUMP1("finish ip_ruby_cmd_core");
return ret;
>
--
Hidetoshi NAGAI
(nagai@ai.kyutech.ac.jp)