From 262a2483e271b141b314468f485fe48d141b4341 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 31 Mar 2006 20:13:41 +0000 Subject: [PATCH] I woulnd't say the classical last words... but I seem to have fixed latest crashes... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16943 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 45 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 021fdb356e..399b1e7e56 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1120,13 +1120,10 @@ BMenu::_hide() // Delete the menu window used by our submenus DeleteMenuWindow(); - if (Supermenu() == NULL) { - // It's our window. Quit it. + window->Unlock(); + + if (fSuper == NULL && window->Lock()) window->Quit(); - } else { - // _show() expects the window to be unlocked - window->Unlock(); - } } @@ -1225,33 +1222,31 @@ BMenu::_AddItem(BMenuItem *item, int32 index) UnlockLooper(); return false; } - - item->SetSuper(this); - - // Make sure we update the layout in case we are already attached. - if (fResizeToFit && locked && Window() != NULL /*&& !Window()->IsHidden()*/) { - LayoutItems(index); - //UpdateWindowViewSize(); - Invalidate(); - } - - // Find the root menu window, so we can install this item. - // ToDo: this shouldn't be necessary - the first supermenu is - // already initialized to the same window - BMenu* root = this; - while (root->Supermenu()) - root = root->Supermenu(); - - BWindow* window = root->Window(); + + // install the item on the supermenu's window + // or onto our window, if we are a root menu + BWindow* window = NULL; + if (Superitem() != NULL) + window = Superitem()->fWindow; + else + window = Window(); if (locked) UnlockLooper(); + item->SetSuper(this); + // if we need to install the item in another window, we don't // want to keep our lock to prevent deadlocks - if (window && window->Lock()) { item->Install(window); + + // Make sure we update the layout if needed. + if (fResizeToFit) { + LayoutItems(index); + //UpdateWindowViewSize(); + Invalidate(); + } window->Unlock(); }