Gtk_widget_queue_draw discared while drawing in multiple times



I have to draw something that take some time in a GtkDrawingArea. As it could be slow, and not feel reactive, I want to do this by slice. So I connected the GtkDrawingArea draw function with gtk_drawing_area_set_draw_func.

In the draw function, I

  • draw a part of the image (if drawing is not yet complete), stopping when x ms have passed and then
  • call gtk_widget_queue_draw on the same GtkDrawingArea to queue the rest of the drawing for later (if drawing is not yet complete)

But this gtk_widget_queue_draw seem to be discarded.

Is there a way to actually queue a draw call to GtkDrawingArea to split the drawing ?


The correct way would be to perform the slow computation in a separate thread, and schedule a queue_draw in idle once it’s complete.

If you really want to do the way you describe, maybe try this:

g_idle_add_once (gtk_widget_queue_draw, widget);
1 Like

Thanks !

Waiting for the slow computation completion won’t work in my case, so i’ll try g_idle_add_once.