How to redraw the application window of a multithreaded GTK app?



Hello,

I'm developing a multithreaded application based on GTK+ 1.2. The main
thread creates the application window and calls gtk_main() then. The
application window comprises a menu, a drawing area and a status bar.

The drawing area is intended to display a GdkImage created and manipulated
by another thread. This thread calls gtk_widget_queue_draw() periodically
(10 to 15 times per second) to let the expose_event handler of the drawing
area draw the GdkImage.

Now my problem is that the application sometimes refreshes the window as
expexted, and sometimes it doesn't. Even sometimes it runs perfectly for
several seconds and then the display freezes.

This behaviour is not determinable. If I stop and restart the application,
the behaviour may differ from the previous run.

I have surrounded all GTK operations in the background thread (i.e.
manipulation of the GdkImage as well as the calls of
gtk_widget_queue_draw()) by pairs of gdk_threads_enter() and
gdk_threads_leave(). But that didn't help.

Also the call of gdk_draw_image() in my expose_event handler is surrounded
by gdk_threads_enter() and gdk_threads_leave().

Moreover, my expose_event handler executes the loop "while (g_main_iteration
(FALSE));" to process all all outstanding events. The implementation of this
loop improved the situation, but the problem described above still occurs.

Does anyone have an idea about this problem?

Regards,
Joerg




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