1
votes

I'm developing an application that periodically draws images on a GTK Drawing Area inside a window.

The rendering first works well and the window content gets repainted if I drag another window over the drawing one, but after some random amount of time (some seconds), the window stops updating itself.

New images dont get displayed, and if I then drag another window over the rendering one I get this:

Window content not updated anymore

When I click one of the checkboxes below my drawing area, the window gets refreshed and the problem is gone for another few seconds.

Any idea what could make the GTK threads stop updating the window content?

I dont know which part of my code is of interest to answer that question, so I pasted the mostly full version here.

My GTK-main() is called like this:

void window_main()
{
    pthread_create(&drawing_thread, NULL, img_draw, NULL);

    gtk_main();

    gdk_threads_leave();
}

Thanks for any hints! :)

1
Okay I traced the problem further down: the drawing area widget does not receive any exposure-events any more. Thats why it is not redrawn. Question is why...lynix

1 Answers

2
votes

Found the solution: in the original example code I used (here) they use a g_timeout_add() to register their periodic drawing function.

The g_timeout_add()-registered function is run by gtk_main(), which means it is protected internally by gdk_threads_enter() and gdk_threads_leave(). That's the point I was not aware of.

Surrounded my call to gtk_widget_queue_draw_area() with these two functions and the bug is gone 8)