Commit a6eda97d authored by Matthias Clasen's avatar Matthias Clasen

menu markup: tolerate not having a hash table of objects

Various places in the code were assuming that the hash table was always
available. Fix this, and also avoid leaking strings now that the hash
table may be NULL.

Based on a patch by Simon McVittie, bug 666167
parent e129deb0
......@@ -138,19 +138,20 @@ g_menu_markup_start_element (GMarkupParseContext *context,
if (!(state-> || state-> || state->string))
if (!(state-> || state->frame.item || state->string))
/* Can only have <menu> here. */
if (g_str_equal (element_name, "menu"))
gchar *id;
if (COLLECT (STRDUP, "id", &id))
if (COLLECT (STRING, "id", &id))
GMenu *menu;
menu = g_menu_new ();
g_hash_table_insert (state->objects, id, menu);
if (state->objects)
g_hash_table_insert (state->objects, g_strdup (id), menu);
g_menu_markup_push_frame (state, menu, NULL);
......@@ -244,7 +245,7 @@ g_menu_markup_start_element (GMarkupParseContext *context,
g_menu_item_set_link (state->frame.item, name, G_MENU_MODEL (menu));
g_menu_markup_push_frame (state, menu, NULL);
if (id != NULL)
if (id != NULL && state->objects)
g_hash_table_insert (state->objects, g_strdup (id), g_object_ref (menu));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment