From b4fb2d9b3e1fe2b4862f68aa679b05b5a25154ad Mon Sep 17 00:00:00 2001 From: Prism Tutaj Date: Sun, 8 Sep 2019 03:10:47 -0500 Subject: [PATCH] Fix GTK submenus --- src/xenia/ui/window_gtk.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xenia/ui/window_gtk.cc b/src/xenia/ui/window_gtk.cc index f310d6a9d..c93e9857d 100644 --- a/src/xenia/ui/window_gtk.cc +++ b/src/xenia/ui/window_gtk.cc @@ -481,14 +481,20 @@ GTKMenuItem::~GTKMenuItem() { void GTKMenuItem::OnChildAdded(MenuItem* generic_child_item) { auto child_item = static_cast(generic_child_item); + GtkWidget* submenu = nullptr; switch (child_item->type()) { case MenuItem::Type::kNormal: // Nothing special. break; case MenuItem::Type::kPopup: if (GTK_IS_MENU_ITEM(menu_)) { - assert(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_)) == nullptr); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_), child_item->handle()); + submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_)); + // Get sub menu and if it doesn't exist create it + if(submenu == nullptr) { + submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_), submenu); + } + gtk_menu_shell_append(GTK_MENU_SHELL(submenu), child_item->handle()); } else { gtk_menu_shell_append(GTK_MENU_SHELL(menu_), child_item->handle()); } @@ -497,7 +503,7 @@ void GTKMenuItem::OnChildAdded(MenuItem* generic_child_item) { case MenuItem::Type::kString: assert(GTK_IS_MENU_ITEM(menu_)); // Get sub menu and if it doesn't exist create it - GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_)); + submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_)); if (submenu == nullptr) { submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_), submenu);