diff options
author | Cody Hein <skmagiik@gmail.com> | 2023-01-03 13:22:08 -0700 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-01-07 19:57:57 +0000 |
commit | 9a05175a88bcff7ed461d67fc78ef354b7f12f67 (patch) | |
tree | d8740e25d0c6e388178c30743dd606c4408700e3 /Userland | |
parent | 8a87aa85ae898e72efa826ef58ec8e53a0b9bd4a (diff) | |
download | serenity-9a05175a88bcff7ed461d67fc78ef354b7f12f67.zip |
WindowServer: Do not add existing menu items (by ptr) to m_menus
This resolves a fixme requesting that we do not add duplicate menus
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/WindowServer/Menubar.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Services/WindowServer/Menubar.h b/Userland/Services/WindowServer/Menubar.h index d05b18dcf0..3e5ee3fa7c 100644 --- a/Userland/Services/WindowServer/Menubar.h +++ b/Userland/Services/WindowServer/Menubar.h @@ -18,7 +18,20 @@ class Menubar { public: void add_menu(Menu& menu, Gfx::IntRect window_rect) { - // FIXME: Check against duplicate menu additions. + bool duplicate_menu_detected = false; + + for_each_menu([&](Menu& existing_menu) { + if (&menu == &existing_menu) { + dbgln("Duplicate Menu \"{}\" ({})", menu.name(), &menu); + duplicate_menu_detected = true; + return IterationDecision::Break; + } + return IterationDecision::Continue; + }); + if (duplicate_menu_detected) { + return; + } + m_menus.append(menu); layout_menu(menu, window_rect); } |