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

This commit is contained in:
joshmoz@gmail.com 2008-03-04 00:11:29 -08:00
parent 44ff54098e
commit b783e916ab

View File

@ -1046,7 +1046,10 @@ nsMenuX::ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aContent, n
menuParent->GetNativeData(&clientData);
if (clientData) {
NSMenu* parentMenu = reinterpret_cast<NSMenu*>(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;
}
}