From daf130da2805182e84b94dea0e007b27382cdec9 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Tue, 4 Mar 2008 08:11:29 +0000 Subject: [PATCH] protect against exception being thrown when trying to remove a native menu item from a menu it isn't in. b=420640 r=smichaud sr=roc git-svn-id: svn://10.0.0.236/trunk@246983 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/cocoa/nsMenuX.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mozilla/widget/src/cocoa/nsMenuX.mm b/mozilla/widget/src/cocoa/nsMenuX.mm index 1a767134ec3..b46f12f6b1f 100644 --- a/mozilla/widget/src/cocoa/nsMenuX.mm +++ b/mozilla/widget/src/cocoa/nsMenuX.mm @@ -1046,7 +1046,10 @@ nsMenuX::ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aContent, n menuParent->GetNativeData(&clientData); if (clientData) { NSMenu* parentMenu = reinterpret_cast(clientData); - [parentMenu removeItem:mNativeMenuItem]; + // An exception will get thrown if we try to remove an item that isn't + // in the menu. + if ([parentMenu indexOfItem:mNativeMenuItem] != -1) + [parentMenu removeItem:mNativeMenuItem]; mVisible = PR_FALSE; } }