From 633645bca91b3a70bd8829ad00bf5b80f6721cf3 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 19 Nov 2008 04:01:05 +0000 Subject: [PATCH] Fix a potential race condition in BPopUpMenu: if Go() is called on an async popup menu that hasn't yet been completely dismissed, it's possible to hit a debugger call because the menu's view tries to add itself to the menu window before the previous menu instance has removed it. This was quite easy to hit with things like BColumnListView's column title context menu, since there is no notification for when the menu was dismissed without invoking an item, and thus double right clicking quickly enough would hit the debugger. Go() now checks if the menu's tracking thread is still up, and if it is, waits for it to go away before trying to start another instance. Fixes ticket #3146. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28693 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/PopUpMenu.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index 1164595fee..040cb9e8b1 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -317,6 +317,13 @@ BMenuItem * BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened, BRect *_specialRect, bool async) { + if (fTrackThread >= B_OK) { + // we already have an active menu, wait for it to go away before + // spawning another + status_t unused; + while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED) + ; + } popup_menu_data *data = new (std::nothrow) popup_menu_data; if (!data) return NULL;