--- old/src/macosx/native/sun/awt/AWTWindow.m 2013-07-19 18:23:35.385582300 +0400 +++ new/src/macosx/native/sun/awt/AWTWindow.m 2013-07-19 18:23:35.218572800 +0400 @@ -541,8 +541,11 @@ AWTWindow *opposite = [AWTWindow lastKeyWindow]; if (!IS(self.styleBits, IS_DIALOG)) { [CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; - } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) { - [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES]; + } else { + if ((opposite != NULL) && IS(self.styleBits, IS_MODAL) + && opposite->javaMenuBar != NULL) { + [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES]; + } } [AWTWindow setLastKeyWindow:nil]; --- old/src/macosx/native/sun/awt/CMenuBar.m 2013-07-19 18:23:37.127682000 +0400 +++ new/src/macosx/native/sun/awt/CMenuBar.m 2013-07-19 18:23:36.964672600 +0400 @@ -63,7 +63,7 @@ if (excludingAppleMenu && ![currMenu isJavaMenu]) { continue; } - + [currItem setSubmenu:nil]; [theMainMenu removeItemAtIndex:index]; } @@ -154,7 +154,10 @@ // Clean up extra items NSUInteger removedIndex, removedCount = [removedMenuArray count]; for (removedIndex=removedCount; removedIndex > 0; removedIndex--) { - [theMainMenu removeItemAtIndex:[[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue]]; + NSUInteger index = [[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue]; + NSMenuItem *currItem = [theMainMenu itemAtIndex:index]; + [currItem setSubmenu:nil]; + [theMainMenu removeItemAtIndex:index]; } i = cmenuIndex;