Ensure that planner warnings get shown before calculations are run

Linus pointed out that the warning wasn't shown until the main loop got
control back, so even a gtk_widget_show_all() doesn't really help to make
sure that things are shown right then.

This commit adds a little loop to handle all pending gtk_events before
exiting the show_error() function. Now the warning should be shown BEFORE
a potentially slow calculation gets started.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-02-14 07:51:25 -08:00
parent 29bc1e12a4
commit 6b458ad7fa

View file

@ -83,6 +83,9 @@ static void show_error(const char *fmt, ...)
if (!bar_is_visible)
gtk_box_pack_start(GTK_BOX(box), planner_error_bar, FALSE, FALSE, 0);
gtk_widget_show_all(box);
/* make sure this actually gets shown BEFORE the calculations run */
while (gtk_events_pending())
gtk_main_iteration_do(FALSE);
}
void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he)