Threading issues

Hello everyone,

I am aware that there are many people who have asked questions relating
to multi-threaded Gtk applications. However, after much trawling through
the Internet I still can’t work out why the following simple code will
not produce any output:

require ‘gtk2’

Thread.new do
sleep 1 # Look busy
exit # Finished, exit
end

Main loop

loop do

Process all currently pending events

Gtk.main_iteration while Gtk.events_pending?
print ‘.’
end

It seems as if the sleeping thread is causing events to be fired,
because Gtk.events_pending? remains true the whole time. This doesn’t
sound right, but I can’t think of a better explanation for the code’s
behaviour. The problem is that the UI will freeze while the other thread
is running (I found this out whilst using Gtk.main, but a custom loop
displays the issue more clearly).

My Gtk wizardry is quite limited, so I would appreciate any help :slight_smile:

Thanks,
Aiden

Le vendredi 29 janvier 2010 à 23:54 +0100, Aiden Nibali a écrit :

sleep 1 # Look busy
exit # Finished, exit
end

Main loop

loop do

Process all currently pending events

Gtk.main_iteration while Gtk.events_pending?
print ‘.’
end

It produces plenty of output here (fills my screen with dots immediatly)

Pascal T. wrote:

It produces plenty of output here (fills my screen with dots immediatly)

That’s very strange. What is your environment like? I’m running Ruby
1.8.7 on Ubuntu Karmic Koala (32-bit) with the Ruby Gtk bindings found
in the repositories, and I get no output at all :frowning:

Pascal T. wrote:

See
Thread: [ruby-gnome2-devel-en] ruby-gnome2 not fully functional (at least for me) in latest ubuntu (karmic) | Ruby-GNOME 2
then, and teport it to launchpad to get the fix in Ubuntu

Thanks for the pointer. I have installed the latest version of ruby-gtk2
now and it works perfectly, filling my screen with glorious dots. I have
reported the bug at
Bug #514899 “Multithreaded Gtk applications using Ruby bindings ...” : Bugs : ruby-gnome2 package : Ubuntu.

Le samedi 30 janvier 2010 à 01:25 +0100, Aiden Nibali a écrit :

Pascal T. wrote:

It produces plenty of output here (fills my screen with dots immediatly)

That’s very strange. What is your environment like? I’m running Ruby
1.8.7 on Ubuntu Karmic Koala (32-bit) with the Ruby Gtk bindings found
in the repositories, and I get no output at all :frowning:

See
http://sourceforge.net/mailarchive/forum.php?thread_name=dc3bf8581001120746kb5da118udd0a74439cc4dcd9%40mail.gmail.com&forum_name=ruby-gnome2-devel-en
then, and teport it to launchpad to get the fix in Ubuntu

Thanks for the pointer. I have installed the latest version of ruby-gtk2
now and it works perfectly, filling my screen with glorious dots. I have

Can you tell me how did you do that? Unless you’ve done it manually,
I’m interested in instructions for other users…


Guillaume C. - Guillaume Cottenceau

Can you tell me how did you do that? Unless you’ve done it manually,
I’m interested in instructions for other users…

Unfortunately I had to build ruby-gtk2 0.19.3 from source. However, it
looks as if the problem will be solved in Ubuntu 10.4, as this is the
version which will be used for that release :slight_smile: