Bug 1442938: Nil-check the title in nsCocoaWindow::importState / exportState. r=mstange
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 03 Mar 2018 18:47:41 +0100
changeset 462039 4b56d0a2859f9da961078be439102101290d8170
parent 462038 10dbb119af2b915f5fa926b89fb97e983b79e7c6
child 462040 e6069d8a3dafd6bbb06b321562adcd5aa55f9c4e
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1442938, 1439875
milestone60.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 1442938: Nil-check the title in nsCocoaWindow::importState / exportState. r=mstange Looking at the docs for [NSWindow title] I don't think it's supposed to return nil under any circumstances... But it does in our automation, for some reason, with the patches for bug 1439875 which make our fullscreen code run a bit earlier. MozReview-Commit-ID: AX4qzjzsqST
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -3193,28 +3193,32 @@ static const NSString* kStateTitleKey = 
 static const NSString* kStateDrawsContentsIntoWindowFrameKey = @"drawsContentsIntoWindowFrame";
 static const NSString* kStateActiveTitlebarColorKey = @"activeTitlebarColor";
 static const NSString* kStateInactiveTitlebarColorKey = @"inactiveTitlebarColor";
 static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
 static const NSString* kStateCollectionBehavior = @"collectionBehavior";
 
 - (void)importState:(NSDictionary*)aState
 {
-  [self setTitle:[aState objectForKey:kStateTitleKey]];
+  if (NSString* title = [aState objectForKey:kStateTitleKey]) {
+    [self setTitle:title];
+  }
   [self setDrawsContentsIntoWindowFrame:[[aState objectForKey:kStateDrawsContentsIntoWindowFrameKey] boolValue]];
   [self setTitlebarColor:[aState objectForKey:kStateActiveTitlebarColorKey] forActiveWindow:YES];
   [self setTitlebarColor:[aState objectForKey:kStateInactiveTitlebarColorKey] forActiveWindow:NO];
   [self setShowsToolbarButton:[[aState objectForKey:kStateShowsToolbarButton] boolValue]];
   [self setCollectionBehavior:[[aState objectForKey:kStateCollectionBehavior] unsignedIntValue]];
 }
 
 - (NSMutableDictionary*)exportState
 {
   NSMutableDictionary* state = [NSMutableDictionary dictionaryWithCapacity:10];
-  [state setObject:[self title] forKey:kStateTitleKey];
+  if (NSString* title = [self title]) {
+    [state setObject:title forKey:kStateTitleKey];
+  }
   [state setObject:[NSNumber numberWithBool:[self drawsContentsIntoWindowFrame]]
             forKey:kStateDrawsContentsIntoWindowFrameKey];
   NSColor* activeTitlebarColor = [self titlebarColorForActiveWindow:YES];
   if (activeTitlebarColor) {
     [state setObject:activeTitlebarColor forKey:kStateActiveTitlebarColorKey];
   }
   NSColor* inactiveTitlebarColor = [self titlebarColorForActiveWindow:NO];
   if (inactiveTitlebarColor) {