Skip to content

Commit

Permalink
Fix macOS selector crash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Sep 16, 2024
1 parent 05f7297 commit 7841bcc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/COpenSwiftUICore/Overlay/CoreGraphics/CoreColor.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ BOOL CoreColorPlatformColorGetComponents(BOOL system, id color, CGFloat *red, CG
}
#if OPENSWIFTUI_TARGET_OS_OSX
if (system) {
id colorSpace =
NSColorSpaceForCGColorSpace(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
id colorSpace = NSColorSpaceForCGColorSpace(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
NSColor *nameSpaceColor = [color colorUsingColorSpace:colorSpace];
if (nameSpaceColor) {
[nameSpaceColor getRed:red green:green blue: blue alpha: alpha];
Expand All @@ -46,6 +45,12 @@ BOOL CoreColorPlatformColorGetComponents(BOOL system, id color, CGFloat *red, CG
if (!colorClass) {
return nil;
}
#if OPENSWIFTUI_TARGET_OS_OSX
if (system) {
id colorSpace = NSColorSpaceForCGColorSpace(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
return [colorClass colorWithColorSpace:colorSpace components:(CGFloat[]){red, green, blue, alpha} count:4];
}
#endif
return [[colorClass alloc] initWithRed:red green:green blue:blue alpha:alpha];
}

Expand Down

0 comments on commit 7841bcc

Please sign in to comment.