Re: Moving circle program ( redrawing problem )



On Wed, 11 Nov 2009 23:25:43 -0800 (PST)
Youngnoh <youngnoh yahoo com> wrote:
> I am trying to write a program that shows a moving circle with
> pthread and a custom libsigc++ signal to learn how to update a
> drawing. I use a similar method of cairo clock in gtkmm example. If I
> compile and run the program the terminal shows the following error
> message if I click on the window after seeing a moving circle for a
> while (64 iterations of the loop in thread_function).
> 
>     Fatal IO error 11 (Resource temporarily unavailable) on X
> server :0.0.

It isn't working because you are attempting to call gtkmm and libsigc++
methods which are not thread safe in two different threads.  I never
cease to be amazed by the number of people who write multi-threaded
programs and never check whether the functions they call are thread
safe. (There is in fact a GDK global lock available which you can use on
unix-like systems but not windows to make GTK+ thread safe, but if you
do so you should not use libsigc++ methods on the same signal object in
more than one thread, nor use sigc::trackable except with great care,
which means generally you cannot adopt this approach with gtkmm.)

Anyway, in your particular case the simplest thing is to use
Glib::Dispatcher.

Chris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]