WSMenuManager: Fix set_current_menu() not setting the current menu

m_current_menu was being set and then immediately cleared by
close_everyone(). Furthermore, since the menu being set can be a
nullptr, we now also make sure to handle that.

Finally, the logic can be simplified. close on the current menu is not
required, as that is also done by close_everyone().
This commit is contained in:
Shannon Booth 2020-01-09 19:58:55 +13:00 committed by Andreas Kling
parent b37bd28053
commit 2f0eb3e28e
Notes: sideshowbarker 2024-07-19 10:11:05 +09:00

View File

@ -389,18 +389,16 @@ void WSMenuManager::open_menu(WSMenu& menu)
void WSMenuManager::set_current_menu(WSMenu* menu, bool is_submenu)
{
if (!is_submenu && m_current_menu)
m_current_menu->close();
if (menu)
m_current_menu = menu->make_weak_ptr();
if (!is_submenu) {
if (!is_submenu)
close_everyone();
if (menu)
m_open_menu_stack.append(menu->make_weak_ptr());
} else {
m_open_menu_stack.append(menu->make_weak_ptr());
if (!menu) {
m_current_menu = nullptr;
return;
}
m_open_menu_stack.append(menu->make_weak_ptr());
m_current_menu = menu->make_weak_ptr();
}
void WSMenuManager::close_bar()