Lock BMenuBar::_Track() atomically. Fixes #9481
This commit is contained in:
@@ -557,24 +557,22 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
{
|
{
|
||||||
// TODO: Cleanup, merge some "if" blocks if possible
|
// TODO: Cleanup, merge some "if" blocks if possible
|
||||||
fChosenItem = NULL;
|
fChosenItem = NULL;
|
||||||
|
|
||||||
BWindow* window = Window();
|
|
||||||
fState = MENU_STATE_TRACKING;
|
fState = MENU_STATE_TRACKING;
|
||||||
|
|
||||||
BPoint where;
|
BPoint where;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
if (window->Lock()) {
|
if (LockLooper()) {
|
||||||
if (startIndex != -1) {
|
if (startIndex != -1) {
|
||||||
be_app->ObscureCursor();
|
be_app->ObscureCursor();
|
||||||
_SelectItem(ItemAt(startIndex), true, false);
|
_SelectItem(ItemAt(startIndex), true, false);
|
||||||
}
|
}
|
||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
window->Unlock();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fState != MENU_STATE_CLOSED) {
|
while (fState != MENU_STATE_CLOSED) {
|
||||||
bigtime_t snoozeAmount = 40000;
|
bigtime_t snoozeAmount = 40000;
|
||||||
if (Window() == NULL || !window->Lock())
|
if (!LockLooper())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BMenuItem* menuItem = NULL;
|
BMenuItem* menuItem = NULL;
|
||||||
@@ -587,7 +585,7 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
// call _Track() from the selected sub-menu when the mouse cursor
|
// call _Track() from the selected sub-menu when the mouse cursor
|
||||||
// is over its window
|
// is over its window
|
||||||
BMenu* menu = fSelected->Submenu();
|
BMenu* menu = fSelected->Submenu();
|
||||||
window->Unlock();
|
UnlockLooper();
|
||||||
snoozeAmount = 30000;
|
snoozeAmount = 30000;
|
||||||
bool wasSticky = _IsStickyMode();
|
bool wasSticky = _IsStickyMode();
|
||||||
menu->_SetStickyMode(wasSticky);
|
menu->_SetStickyMode(wasSticky);
|
||||||
@@ -602,9 +600,9 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
// where to store the current mouse position ?
|
// where to store the current mouse position ?
|
||||||
// (Or just use the BView mouse hooks)
|
// (Or just use the BView mouse hooks)
|
||||||
BPoint newWhere;
|
BPoint newWhere;
|
||||||
if (window->Lock()) {
|
if (LockLooper()) {
|
||||||
GetMouse(&newWhere, &buttons);
|
GetMouse(&newWhere, &buttons);
|
||||||
window->Unlock();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code is needed to make menus
|
// This code is needed to make menus
|
||||||
@@ -619,7 +617,7 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
} else
|
} else
|
||||||
fState = MENU_STATE_CLOSED;
|
fState = MENU_STATE_CLOSED;
|
||||||
}
|
}
|
||||||
if (!window->Lock())
|
if (!LockLooper())
|
||||||
break;
|
break;
|
||||||
} else if (menuItem != NULL) {
|
} else if (menuItem != NULL) {
|
||||||
if (menuItem->Submenu() != NULL && menuItem != fSelected) {
|
if (menuItem->Submenu() != NULL && menuItem != fSelected) {
|
||||||
@@ -642,7 +640,7 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
fState = MENU_STATE_TRACKING;
|
fState = MENU_STATE_TRACKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->Unlock();
|
UnlockLooper();
|
||||||
|
|
||||||
if (fState != MENU_STATE_CLOSED) {
|
if (fState != MENU_STATE_CLOSED) {
|
||||||
// If user doesn't move the mouse, loop here,
|
// If user doesn't move the mouse, loop here,
|
||||||
@@ -680,14 +678,14 @@ BMenuBar::_Track(int32* action, int32 startIndex, bool showMenu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->Lock()) {
|
if (LockLooper()) {
|
||||||
if (fSelected != NULL)
|
if (fSelected != NULL)
|
||||||
_SelectItem(NULL);
|
_SelectItem(NULL);
|
||||||
|
|
||||||
if (fChosenItem != NULL)
|
if (fChosenItem != NULL)
|
||||||
fChosenItem->Invoke();
|
fChosenItem->Invoke();
|
||||||
_RestoreFocus();
|
_RestoreFocus();
|
||||||
window->Unlock();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_IsStickyMode())
|
if (_IsStickyMode())
|
||||||
|
|||||||
Reference in New Issue
Block a user