vlc | branch: master | Marvin Scholz <epira...@gmail.com> | Fri Oct 23 13:11:29 2015 +0200| [bf294ee5cc3830b05a4505fb1624191b70244e81] | committer: Jean-Baptiste Kempf
osx_notifications: Check if user notifications classes exist to prevent crash on 10.7 Add checks for NSUserNotification and NSUserNotificationCenter so we do not use them on OS X 10.7 and below, to prevent VLC from crashing if it is compiled on 10.8 or higher but ran on 10.7 or below. Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf294ee5cc3830b05a4505fb1624191b70244e81 --- modules/notify/osx_notifications.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/notify/osx_notifications.m b/modules/notify/osx_notifications.m index 914787d..8fb03d8 100644 --- a/modules/notify/osx_notifications.m +++ b/modules/notify/osx_notifications.m @@ -87,6 +87,7 @@ NSMutableDictionary *registrationDictionary; id lastNotification; bool isInForeground; + bool hasNativeNotifications; intf_thread_t *interfaceThread; } @@ -299,6 +300,12 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, // Start in background isInForeground = NO; + // Check for native notification support + Class userNotificationClass = NSClassFromString(@"NSUserNotification"); + Class userNotificationCenterClass = NSClassFromString(@"NSUserNotificationCenter"); + hasNativeNotifications = (userNotificationClass && userNotificationCenterClass) ? YES : NO; + + lastNotification = nil; applicationName = nil; notificationType = nil; registrationDictionary = nil; @@ -312,7 +319,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 // Clear the remaining lastNotification in Notification Center, if any @autoreleasepool { - if (lastNotification) { + if (lastNotification && hasNativeNotifications) { [NSUserNotificationCenter.defaultUserNotificationCenter removeDeliveredNotification:(NSUserNotification *)lastNotification]; [lastNotification release]; @@ -344,8 +351,10 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, [GrowlApplicationBridge setGrowlDelegate:self]; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 - [[NSUserNotificationCenter defaultUserNotificationCenter] - setDelegate:(id<NSUserNotificationCenterDelegate>)self]; + if (hasNativeNotifications) { + [[NSUserNotificationCenter defaultUserNotificationCenter] + setDelegate:(id<NSUserNotificationCenterDelegate>)self]; + } #endif } } @@ -409,7 +418,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, isSticky:NO clickContext:nil identifier:@"VLCNowPlayingNotification"]; - } else { + } else if (hasNativeNotifications) { #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 // Make the OS X notification and string NSUserNotification *notification = [NSUserNotification new]; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits