Commit 3030b78
committed
cocoa_gl_ctx: runtime-guard setColorSpace: for pre-10.6 Leopard
On 10.5 Leopard, RetroArch crashes during GL context creation:
[NSWindow setColorSpace:]: unrecognized selector sent to
instance 0x631bad0
-[NSWindow setColorSpace:] is annotated NS_AVAILABLE_MAC(10_6).
Snow Leopard introduced color-space-aware window tagging; 10.5's
NSWindow doesn't have the selector.
Same class of runtime issue as aa5c926 (setHelpMenu:) and the
URLForResource: guard: compile succeeds because messages to id
dispatch dynamically, but the Obj-C runtime can't resolve the
selector at dispatch time and throws NSInvalidArgumentException.
Runtime-guard with respondsToSelector::
NSWindow *win = [g_view window];
if ([win respondsToSelector:@selector(setColorSpace:)])
[win setColorSpace:[NSColorSpace sRGBColorSpace]];
Wrapped in a block so the local NSWindow* doesn't leak into the
surrounding scope.
+[NSColorSpace sRGBColorSpace] on the same line is 10.5+
(NS_AVAILABLE_MAC(10_5) per the header) so it stays unguarded.
Only the NSWindow selector is the 10.6 addition.
Behavioral impact on Leopard: windows use the system default color
space, which is what Leopard always did anyway - color-space-aware
window tagging didn't exist pre-10.6. Modern macOS still gets the
explicit sRGB tag as before.1 parent db35429 commit 3030b78
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
442 | 452 | | |
443 | 453 | | |
444 | 454 | | |
| |||
0 commit comments