Verbose Logging

software development with some really amazing hair

T + S G I F R

Gtk And Ruby Threading Issues

· · Posted in Programming
Tagged with

In one of my classes, we used Ruby and Gtk, but some issues popped up. The most obvious is using a block to do GUI update stuff and the like, from another thread. Things die. Puppies are killed.

I found this post on Ruby Forum which fixed the problem.

Relevant code.

Basically, you call the Gtk.init_thread_protect method first when you start things up, then, whenever you need to do GUI update stuff, just wrap it in a Gtk.thread_protect {} block. Voila! It works. No more crashes. In looking at this code again now, some things could be made more Rubyesque, but we'll go with it.

My version with minor changes:


Sharing is Caring