Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro
authorMarkus Stange <mstange@themasta.com>
Wed, 07 Nov 2018 21:38:21 +0000
changeset 445035 8104ed0591679d8e4baac5d2419315ccb48451e6
parent 445034 1d6dba09c494831d64a419c0c5258827f839c708
child 445036 640b4bd3443840a7be5503663048b14c0899cd93
push id35007
push useraiakab@mozilla.com
push dateThu, 08 Nov 2018 04:46:54 +0000
treeherdermozilla-central@18ea6c93e858 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1503424
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro Differential Revision: https://phabricator.services.mozilla.com/D11239
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3051,21 +3051,23 @@ nsChildView::SetPrefersReducedMotionOver
   lookAndFeelCache.AppendElement(prefersReducedMotion);
 
   // If we could have a way to modify
   // NSWorkspace.accessibilityDisplayShouldReduceMotion, we could use it, but
   // unfortunately there is no way, so we change the cache value instead as if
   // it's set in the parent process.
   LookAndFeel::SetIntCache(lookAndFeelCache);
 
-  if (nsCocoaFeatures::OnMojaveOrLater()) {
+  if (nsCocoaFeatures::OnMojaveOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[[NSWorkspace sharedWorkspace] notificationCenter]
          postNotificationName: NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
          object:nil];
-  } else if (nsCocoaFeatures::OnYosemiteOrLater()) {
+  } else if (nsCocoaFeatures::OnYosemiteOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[NSNotificationCenter defaultCenter]
        postNotificationName: NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
        object:nil];
   } else {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
@@ -3310,23 +3312,25 @@ NSEvent* gLastDragMouseDownEvent = nil;
                                            selector:@selector(systemMetricsChanged)
                                                name:NSControlTintDidChangeNotification
                                              object:nil];
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(systemMetricsChanged)
                                                name:NSSystemColorsDidChangeNotification
                                              object:nil];
 
-  if (nsCocoaFeatures::OnMojaveOrLater()) {
+  if (nsCocoaFeatures::OnMojaveOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[[NSWorkspace sharedWorkspace] notificationCenter]
            addObserver:self
               selector:@selector(systemMetricsChanged)
                   name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
                 object:nil];
-  } else if (nsCocoaFeatures::OnYosemiteOrLater()) {
+  } else if (nsCocoaFeatures::OnYosemiteOrLater() &&
+             NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(systemMetricsChanged)
                                                  name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
                                                object:nil];
   }
 
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(scrollbarSystemMetricChanged)