Commit db35429
committed
platform_darwin: runtime-guard URLForResource: for pre-10.6 Leopard
On 10.5 Leopard, RetroArch crashes at startup during default-dir
setup:
[NSBundle URLForResource:withExtension:subdirectory:]:
unrecognized selector sent to instance 0x632d410
-[NSBundle URLForResource:withExtension:subdirectory:] is annotated
NS_AVAILABLE(10_6, 4_0) in the 10.8 SDK header - added in Snow
Leopard as part of NSBundle's URL-based API. 10.5 NSBundle only
has the older pathForResource:-style methods returning NSString *.
Same class of issue as setHelpMenu: (aa5c926): compile succeeds
because messages to id dispatch dynamically, but the runtime can't
resolve the selector and throws NSInvalidArgumentException. Use
the same pre-Obj-C-2.0 idiom:
if ([[NSBundle mainBundle] respondsToSelector:
@selector(URLForResource:withExtension:subdirectory:)])
url = [[NSBundle mainBundle] URLForResource:...];
Both callers in this file (DEFAULT_DIR_AUDIO_FILTER and
DEFAULT_DIR_VIDEO_FILTER setup) already have a fill_pathname_join
fallback for the url==nil case, so the guard just needs to keep
url nil on 10.5. Cache the SEL in a local since both calls use
the same selector.
Behavioral impact on Leopard: no bundle-shipped filter auto-
discovery; audio/video filter dirs always resolve to
application_data/filters/{audio,video} via the existing fallback.
That's RetroArch's conventional path anyway - the URLForResource:
trick is only an optimization for bundles that ship filters inline,
which is rare on desktop macOS. Modern macOS behavior unchanged.
Other NSBundle methods in this file (objectForInfoDictionaryKey:
at lines 392, 491) are 10.0-era and need no guard.1 parent aa5c926 commit db35429
1 file changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
448 | 457 | | |
449 | 458 | | |
450 | 459 | | |
451 | 460 | | |
452 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
453 | 464 | | |
454 | 465 | | |
455 | 466 | | |
| |||
0 commit comments