Don't crash on null QCoocaMenuItem.

Change-Id: Ia70f616983141134afe874b69a5957e31f6f5ed9
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Morten Johan Sørvig 2013-04-26 11:14:21 +02:00 committed by The Qt Project
parent c90d9b697f
commit f8e2a8469f

View File

@ -371,7 +371,8 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
NSMenuItem *item = reinterpret_cast<NSMenuItem *>([itemArray objectAtIndex:i]);
if ([item isSeparatorItem]) {
QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>([item tag]);
cocoaItem->setVisible(!previousIsSeparator);
if (cocoaItem)
cocoaItem->setVisible(!previousIsSeparator);
[item setHidden:previousIsSeparator];
}
@ -384,7 +385,8 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
// We now need to check the final item since we don't want any separators at the end of the list.
if (previousItem && previousIsSeparator) {
QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>([previousItem tag]);
cocoaItem->setVisible(false);
if (cocoaItem)
cocoaItem->setVisible(false);
[previousItem setHidden:YES];
}
} else {