diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index 8c00006d9..26ae6da2b 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -148,6 +148,13 @@ var _CPMenuBarVisible = NO, return _CPMenuBarImage; } ++ (void)_setOrRemoveMenuBarAttribute:(id)aValue forKey:(id)aKey +{ + if (aValue === nil) + [_CPMenuBarAttributes removeObjectForKey:aKey]; + else + [_CPMenuBarAttributes setObject:aValue forKey:aKey]; +} + (void)setMenuBarAttributes:(CPDictionary)attributes { @@ -172,8 +179,8 @@ var _CPMenuBarVisible = NO, else if (!textColor && !titleColor) { - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextColor"]; - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleColor"]; } if (!textShadowColor && titleShadowColor) @@ -184,18 +191,18 @@ var _CPMenuBarVisible = NO, else if (!textShadowColor && !titleShadowColor) { - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextShadowColor"]; - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleShadowColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextShadowColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleShadowColor"]; } if (!highlightColor) - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightColor"]; if (!highlightTextColor) - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextColor"]; if (!highlightTextShadowColor) - [_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextShadowColor"]; + [self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextShadowColor"]; if (_CPMenuBarSharedWindow) { diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 3aedfa2e7..53b90ee1d 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -1156,8 +1156,14 @@ The sum of the views and the sum of the dividers should be equal to the size of { _preCollapsePositions = [CPMutableDictionary new]; - for (var i = 0, count = [preCollapseArray count]; i < count; i++) - [_preCollapsePositions setObject:preCollapseArray[i] forKey:i + ""]; + for (var i = 0, count = [preCollapseArray count]; i < count; i++) { + var item = preCollapseArray[i]; + + if (item === nil) + [_preCollapsePositions removeObjectForKey:i + ""]; + else + [_preCollapsePositions setObject:item forKey:i + ""]; + } } } diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index dc0dc5307..64bd54560 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -27,6 +27,9 @@ @import "CPObject.j" #import "Ref.h" +//FIXME: After release of 0.9.7 remove below variable +var deprecatedMessage = YES; + /* @ignore */ @implementation _CPDictionaryValueEnumerator : CPEnumerator { @@ -260,8 +263,19 @@ { var i = [keyArray count]; - while (i--) - [self setObject:objects[i] forKey:keyArray[i]]; + while (i--) { + var aValue = objects[i], + aKey = keyArray[i]; + + if (aValue === nil || aKey === nil) { + deprecatedMessage = NO; + CPLog.warn(@"[" + [self className] + @" " + _cmd + @"DEPRECATED: Attempt to insert nil object from objects[" + i + @"]"); + objj_backtrace_print(CPLog.warn); + //FIXME: After release of 0.9.7 remove variable deprecatedMessage and change above line to this: + //[CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + i + @"]"]; + } + [self setObject:aValue forKey:aKey]; + } } return self; @@ -297,12 +311,18 @@ for (; index < argCount; index += 2) { - var value = arguments[index]; + var value = arguments[index], + aKey = arguments[index + 1]; - if (value === nil) - continue; + if (value === nil || aKey === nil) { + deprecatedMessage = NO; + CPLog.warn(@"[" + [self className] + @" " + _cmd + @"DEPRECATED: Attempt to insert nil object from objects[" + (index / 2 - 1) + @"]"); + objj_backtrace_print(CPLog.warn); + //FIXME: After release of 0.9.7 remove variable deprecatedMessage and change above line to this: + //[CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + (index / 2 - 1) + @"]"]; + } - [self setObject:value forKey:arguments[index + 1]]; + [self setObject:value forKey:aKey]; } } @@ -611,6 +631,22 @@ */ - (void)setObject:(id)anObject forKey:(id)aKey { + if (deprecatedMessage && aKey === nil) { + CPLog.warn(@"[" + [self className] + @" " + _cmd + @"] DEPRECATED: Key cannot be nil"); + objj_backtrace_print(CPLog.warn); + //FIXME: After release of 0.9.7 change above line to this: + //[CPException raise:CPInvalidArgumentException reason:@"Key cannot be nil"]; + } + + if (deprecatedMessage && anObject === nil) { + CPLog.warn(@"[" + [self className] + @" " + _cmd + @"] DEPRECATED: Object cannot be nil (key: " + aKey + @")"); + objj_backtrace_print(CPLog.warn); + //FIXME: After release of 0.9.7 change above line to this: + //[CPException raise:CPInvalidArgumentException reason:@"Object cannot be nil (key: " + aKey + @")"]; + } + + //FIXME: After release of 0.9.7 remove below line. + deprecatedMessage = YES; self.setValueForKey(aKey, anObject); } diff --git a/Foundation/CPKeyedArchiver.j b/Foundation/CPKeyedArchiver.j index 80f7a6689..e4e0d7bbd 100644 --- a/Foundation/CPKeyedArchiver.j +++ b/Foundation/CPKeyedArchiver.j @@ -503,7 +503,8 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) } } - [self._replacementObjects setObject:object forKey:GUID]; + if (object != nil && GUID != nil) + [self._replacementObjects setObject:object forKey:GUID]; } // If we still don't have an object by this point, then return a diff --git a/Foundation/CPUserDefaults.j b/Foundation/CPUserDefaults.j index 967ae83a7..205330d35 100644 --- a/Foundation/CPUserDefaults.j +++ b/Foundation/CPUserDefaults.j @@ -342,7 +342,10 @@ var StandardUserDefaults; var data = [[self persistentStoreForDomain:aDomain] data], domain = data ? [CPKeyedUnarchiver unarchiveObjectWithData:data] : nil; - [_domains setObject:domain forKey:aDomain]; + if (domain === nil) + [_domains removeObjectForKey:aDomain]; + else + [_domains setObject:domain forKey:aDomain]; _searchListNeedsReload = YES; }