diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index 3d15dcaf2ba..0a561ad6673 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -452,6 +452,12 @@ nsMenuBarFrame::Enter() NS_IMETHODIMP nsMenuBarFrame::HideChain() { + // Stop capturing rollups + // (must do this during Hide, which happens before the menu item is executed, + // since this reinstates normal event handling.) + if (nsMenuFrame::mDismissalListener) + nsMenuFrame::mDismissalListener->Unregister(); + if (mCurrentMenu) { mCurrentMenu->ActivateMenu(PR_FALSE); mCurrentMenu->SelectMenu(PR_FALSE); diff --git a/layout/xul/base/src/nsMenuDismissalListener.cpp b/layout/xul/base/src/nsMenuDismissalListener.cpp index fe3ffa357bd..ba010697bbe 100644 --- a/layout/xul/base/src/nsMenuDismissalListener.cpp +++ b/layout/xul/base/src/nsMenuDismissalListener.cpp @@ -109,8 +109,10 @@ nsMenuDismissalListener::Rollup() { if (mEnabled) { if (mMenuParent) { + AddRef(); mMenuParent->HideChain(); mMenuParent->DismissChain(); + Release(); } else Unregister(); diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index fee3283788e..4a05a7fb46b 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -616,6 +616,12 @@ nsMenuPopupFrame::GetParentPopup(nsIMenuParent** aMenuParent) NS_IMETHODIMP nsMenuPopupFrame::HideChain() { + // Stop capturing rollups + // (must do this during Hide, which happens before the menu item is executed, + // since this reinstates normal event handling.) + if (nsMenuFrame::mDismissalListener) + nsMenuFrame::mDismissalListener->Unregister(); + nsIFrame* frame; GetParent(&frame); if (frame) {