I'm using GTK+3 / GDK on Ubuntu 16.
I have a g_timer service routine that does some busy work and then updates some GTK label and graphic widgets.
In some instances I have noticed if the service routine for a GDK timer (setup with g_timeout_add() ) runs long and that the GTK+3 widgets don't get updated from the code inside the service routine. With GTK2 the:
gdk_threads_enter(); ... gdk_threads_exit();
was recommended to resolve this issu. However these GDK thread calls have been deprecated with GTK+3. I can't find any updated documentation other than 'All GDK and GTK+ calls should be made from the main thread'
The only solution I have found so far is to call:
gtk_main_iteration_do(false);
at the end of the timer service routine. Doing this seems to always force the widgets to redraw with the updated data.
So is there another recommended way to deal with this timing problem in GTK+3 or is the gtk_main_interation_do() call acceptable / best practice?
I also have noticed that if I set the interval of the g_timeout_add() too short that my measured execution time of the service routine actually increases. I suspect this may be caused by extra code software interrupt code running in the GDK main loop with respect to this timer. However I don't know how to prove that. Is this observation expected with GTK3 / GDK?