diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index e63ab35b6e..d6df6e8856 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1174,7 +1174,7 @@ BMenu::InitData(BMessage *data) data->FindFloat("_maxwidth", &fMaxContentWidth); BMessage msg; - for (int32 i = 0; data->FindMessage("_items", i, &msg) == B_OK; i++) { + for (int32 i = 0; data->FindMessage("_items", i, &msg) == B_OK; i++) { BArchivable *object = instantiate_object(&msg); if (BMenuItem *item = dynamic_cast(object)) { BRect bounds; diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 9528fc9880..2985a8646e 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -493,6 +493,10 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) void BMenuBar::StealFocus() { + // We already stole the focus, don't do anything + if (fPrevFocusToken != -1) + return; + BWindow *window = Window(); if (window != NULL && window->Lock()) { BView *focus = window->CurrentFocus(); @@ -514,12 +518,12 @@ BMenuBar::RestoreFocus() && gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, (void **)&handler) == B_OK) { BView *view = dynamic_cast(handler); if (view != NULL && view->Window() == window) - view->MakeFocus(); - fPrevFocusToken = -1; + view->MakeFocus(); } else if (IsFocus()) MakeFocus(false); - + + fPrevFocusToken = -1; window->Unlock(); } }