Merge pull request #85 from gnustep/theme_colour_list

Protect against theme colour list missing out on default colours
This commit is contained in:
Fred Kiefer 2020-10-05 19:16:05 +02:00 committed by GitHub
commit 411b2c91a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2020-10-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSColor.m: Protect against theme colour list missing out
on default colours.
2020-09-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSToolTips.m: Revert bogus last commit.

View file

@ -2046,6 +2046,7 @@ systemColorWithName(NSString *name)
NSColorList *list = [theme colors];
NSEnumerator *enumerator;
NSString *name;
NSString *key;
if (list == nil)
{
@ -2065,6 +2066,22 @@ systemColorWithName(NSString *name)
{
[[systemDict objectForKey: name] recache];
}
if (list != defaultSystemColors)
{
// Check that all default colours are definied in the theme
enumerator = [colorStrings keyEnumerator];
while ((key = [enumerator nextObject]) != nil)
{
if ([list colorWithKey: key] == nil)
{
// Add missing colours from the default system colour list
NSColor *color = [defaultSystemColors colorWithKey: key];
[list setColor: color forKey: key];
}
}
}
[[NSNotificationCenter defaultCenter]
postNotificationName: NSSystemColorsDidChangeNotification object: nil];
}
@ -2222,6 +2239,10 @@ static NSRecursiveLock *namedColorLock = nil;
{
list = [NSColorList colorListNamed: _catalog_name];
real = [list colorWithKey: _color_name];
if (real == nil)
{
NSLog(@"Missing colour '%@' in colour list '%@'", _color_name, _catalog_name);
}
ASSIGN(_cached_color, [real colorUsingColorSpaceName: colorSpace
device: deviceDescription]);
ASSIGN(_cached_name_space, colorSpace);