summaryrefslogtreecommitdiff
path: root/Servers/WindowServer
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2020-01-09 19:58:55 +1300
committerAndreas Kling <awesomekling@gmail.com>2020-01-11 18:58:59 +0100
commit2f0eb3e28e6cd02594a330b24226def165d90bd0 (patch)
tree8fb94ee0ddec6e4af2c674283b64fe7859207920 /Servers/WindowServer
parentb37bd280533fe9975ed73f618ae9d157cafcf640 (diff)
downloadserenity-2f0eb3e28e6cd02594a330b24226def165d90bd0.zip
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().
Diffstat (limited to 'Servers/WindowServer')
-rw-r--r--Servers/WindowServer/WSMenuManager.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/Servers/WindowServer/WSMenuManager.cpp b/Servers/WindowServer/WSMenuManager.cpp
index d6c53635a3..26c4780678 100644
--- a/Servers/WindowServer/WSMenuManager.cpp
+++ b/Servers/WindowServer/WSMenuManager.cpp
@@ -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()