src/menu: Handle menu item creation failure

This commit is contained in:
Consolatis 2022-06-12 21:14:48 +02:00 committed by Johan Malm
parent 505f92e733
commit 2aaf26e87b

View file

@ -268,7 +268,11 @@ handle_menu_element(xmlNode *n, struct server *server)
* create an item pointing to the new submenu
*/
current_item = item_create(current_menu, label);
if (current_item) {
submenu = &current_item->submenu;
} else {
submenu = NULL;
}
}
++menu_level;
current_menu = menu_create(server, id, label);
@ -282,7 +286,9 @@ handle_menu_element(xmlNode *n, struct server *server)
struct menu *menu = menu_get_by_id(id);
if (menu) {
current_item = item_create(current_menu, menu->label);
if (current_item) {
current_item->submenu = menu;
}
} else {
wlr_log(WLR_ERROR, "no menu with id '%s'", id);
}