[gnome-logs] Avoid a segfault when updating the boot menu
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] Avoid a segfault when updating the boot menu
- Date: Fri, 7 Jun 2019 14:16:21 +0000 (UTC)
commit 86ae341d6837e7b6b36bd8e0c65be0211ef37eba
Author: David King <amigadave amigadave com>
Date: Fri Jun 7 14:39:33 2019 +0100
Avoid a segfault when updating the boot menu
src/gl-eventtoolbar.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/gl-eventtoolbar.c b/src/gl-eventtoolbar.c
index 8107448..9a8bd5c 100644
--- a/src/gl-eventtoolbar.c
+++ b/src/gl-eventtoolbar.c
@@ -55,13 +55,17 @@ gl_event_toolbar_update_boot_menu_label (GlEventToolbar *toolbar,
boot_menu = gtk_menu_button_get_menu_model (GTK_MENU_BUTTON (priv->menu_button));
section = g_menu_model_get_item_link (boot_menu, 0, "section");
- menu_item = g_menu_item_new_from_model (section, 0);
- g_menu_item_set_label (menu_item, latest_boot);
- g_menu_remove (G_MENU (section), 0);
- g_menu_insert_item (G_MENU (section), 0, menu_item);
+ if (g_menu_model_get_n_items (section) < 0)
+ {
+ menu_item = g_menu_item_new_from_model (section, 0);
+ g_menu_item_set_label (menu_item, latest_boot);
+
+ g_menu_remove (G_MENU (section), 0);
+ g_menu_insert_item (G_MENU (section), 0, menu_item);
- g_object_unref (menu_item);
+ g_object_unref (menu_item);
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]