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
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -3219,28 +3219,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) {