[Java-gnome-developer] A use case of Gtk.mainIterationDo()
Brought to you by:
afcowie
From: Guillaume M. <res...@gm...> - 2011-09-03 14:40:30
|
After releasing the last version of my program[1] a user reported a strange bug caused by the interruption of the GTK main loop. Basically, my program provides an Assistant so the user is guided to split or merge files. In the last page of the assistant, when confirming the split/merge the main window is refreshed with some new data and a thread is started to proceed to the requested action. The tricky point is that the window *must* be fully refreshed before the thread starts. So when the interface is not fully refreshed an error message is displayed and the action is canceled. The origin of the bug I had was just this. The thread interrupted and started before the GTK main loop finish the refresh of the UI. It is invisible to the user because all of this occurs pretty quickly. I finally found a fix for that using 2 recently exposed methods: - Gtk.eventsPending() - Gtk.mainIterationDo() You can take a look at the fix by following this link: - http://trac.gnome-split.org/changeset/265 or by grabbing the code. This fix forces the GTK main loop to run until there is no more things to proceed. What do you think about this fix? -- Guillaume Mazoyer |