From c6278c8f4931339b91b2bb10b5225596203475ee Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 7 May 2009 21:13:24 +0000 Subject: [PATCH] Lock the root menu before calling BMenuItem::Invoke(). This fixes #3842, although in some circumstances could introduce a deadlock (if someone does strange things in Invoke(), for example). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30662 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 61cdb7ff6f..7c4b07c825 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2279,7 +2279,18 @@ BMenu::_InvokeItem(BMenuItem *item, bool now) UnlockLooper(); } - item->Invoke(); + // Lock the root menu window before calling BMenuItem::Invoke() + BMenu *parent = this; + BMenu *rootMenu = NULL; + do { + rootMenu = parent; + parent = rootMenu->Supermenu(); + } while (parent != NULL); + + if (rootMenu->LockLooper()) { + item->Invoke(); + rootMenu->UnlockLooper(); + } }