gtk4-demo: Avoid a critical from a11y code

Even though we want to be accessible,
we must not divide by zero.
This commit is contained in:
Matthias Clasen 2022-10-28 11:59:35 -04:00
parent a13a681910
commit b972decf82

View File

@ -42,7 +42,7 @@ update_title_cb (GtkFilterListModel *model)
title = g_strdup_printf ("%u lines", g_list_model_get_n_items (G_LIST_MODEL (model)));
gtk_widget_set_visible (progress, pending != 0);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), (total - pending) / (double) total);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), total > 0 ? (total - pending) / (double) total : 0.);
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
}