aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbusmenu-gtk/parser.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index 4941bf4..7e5e7e1 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -666,11 +666,19 @@ widget_notify_cb (GtkWidget *widget,
}
/* Now parse new submenu. */
- GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
RecurseContext recurse = {0};
recurse.toplevel = gtk_widget_get_toplevel(widget);
recurse.parent = item;
- parse_menu_structure_helper(menu, &recurse);
+
+ if (item != NULL) {
+ GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+ parse_menu_structure_helper(menu, &recurse);
+ } else {
+ /* Note: it would be really odd that we wouldn't have a cached
+ item, but we should handle that appropriately. */
+ parse_menu_structure_helper(widget, &recurse);
+ g_object_unref(G_OBJECT(recurse.parent));
+ }
}
}