From f8e2a8469f91ac1a7daf73c8ed9c24195e5b5a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 26 Apr 2013 11:14:21 +0200 Subject: [PATCH] Don't crash on null QCoocaMenuItem. Change-Id: Ia70f616983141134afe874b69a5957e31f6f5ed9 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenu.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 565c77fd44..c5c5c132bc 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -371,7 +371,8 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable) NSMenuItem *item = reinterpret_cast([itemArray objectAtIndex:i]); if ([item isSeparatorItem]) { QCocoaMenuItem *cocoaItem = reinterpret_cast([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([previousItem tag]); - cocoaItem->setVisible(false); + if (cocoaItem) + cocoaItem->setVisible(false); [previousItem setHidden:YES]; } } else {