From 35beeaa99fcab37b2404af06c9259ff6cc64efe7 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 28 Mar 2006 20:22:15 +0000 Subject: [PATCH] Minor improvements git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16916 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 7e91fdf525..cd5b7053f6 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -264,8 +265,6 @@ BMenu::AttachedToWindow() free(chars); free(keys); - fAttachAborted = false; - BMenuItem *superItem = Superitem(); BMenu *superMenu = Supermenu(); if (AddDynamicItem(B_INITIAL_ADD)) { @@ -1056,7 +1055,7 @@ BMenu::_show(bool selectFirstItem) // See if the supermenu has a cached menuwindow, // and use that one if possible. BMenuWindow *window = NULL; - + bool ourWindow = false; if (fSuper != NULL) { fSuperbounds = fSuper->ConvertToScreen(fSuper->Bounds()); window = fSuper->MenuWindow(); @@ -1068,16 +1067,30 @@ BMenu::_show(bool selectFirstItem) if (window == NULL) { // Menu windows get the BMenu's handler name window = new BMenuWindow(Name()); + ourWindow = true; } if (window == NULL) return false; if (window->Lock()) { + fAttachAborted = false; window->AttachMenu(this); + // Menu didn't have the time to add its items: aborting... + if (fAttachAborted) { + window->DetachMenu(); + // TODO: Probably not needed, we can just let _hide() quit the window + if (ourWindow) + window->Quit(); + else + window->Unlock(); + return false; + } + // TODO: for some reason, Window() can already be NULL at this point, // which causes a crash in one of the following functions... + // Does this still happens ? UpdateWindowViewSize(); window->Show(); @@ -1134,7 +1147,7 @@ BMenu::_track(int *action, long start) bigtime_t snoozeAmount = 50000; BPoint location; - GetMouse(&location, &buttons, true); + GetMouse(&location, &buttons, false); BPoint screenLocation = ConvertToScreen(location); item = HitTestItems(location, B_ORIGIN); if (item != NULL) {