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
This commit is contained in:
Rene Gollent
2008-11-19 04:01:05 +00:00
parent 6826c30a25
commit 633645bca9
+7
View File
@@ -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;