Skip to content

Commit f8ef764

Browse files
committed
gfx/dispserv_apple: use RARCH_RELEASE for iv so ARC builds also compile
Fixup for 93cdcb8 ('gfx/dispserv_apple: plug two MRC leaks in macOS progress/resolution paths'). The previous patch added a raw '[iv release]' inside the dispatch_once block. That compiled fine under the top-level qb Makefile (this file is not in the per-file -fobjc-arc override list at Makefile:275, so it builds MRC), but every Xcode project in pkg/apple/ builds it under ARC - pkg/apple/BaseConfig.xcconfig:182 sets CLANG_ENABLE_OBJC_ARC=YES at the target level, and each Xcode target compiles griffin/griffin_objc.m as a single umbrella translation unit that #include's dispserv_apple.m (alongside cocoa_input.m, coreaudio3.m, corelocation.m, and the rest of the Apple-specific .m sources). Raw -release is an ARC compile error: error: 'release' is unavailable: not available in automatic reference counting mode error: ARC forbids explicit message send of 'release' Swap '[iv release]' for 'RARCH_RELEASE(iv)'. The macro in libretro-common/include/defines/cocoa_defines.h expands to '[(x) release]' under MRC (preserving the leak fix from 93cdcb8) and to '((void)0)' under ARC, where the compiler inserts the matching release at block-scope exit automatically. cocoa_defines.h is already included at line 29 of this file, so no new header is needed. Also rewrote the adjacent comment to reflect reality - the file compiles under BOTH build systems with different ARC modes, not just MRC as the original comment claimed. This matches the build matrix already documented in Makefile:269-276 and Makefile.common:1649-1665. Thread-safety / reachability: unchanged from 93cdcb8 - this is a build-fix only. Runtime behaviour is identical under qb-MRC (still does [iv release]) and correct by ARC semantics under Xcode (ARC auto-releases on block scope exit).
1 parent 3498771 commit f8ef764

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

gfx/display_servers/dispserv_apple.m

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,32 @@ static bool apple_display_server_set_window_progress(void *data, int progress, b
8484
// Create a custom view for the dock tile
8585
[iv addSubview:indicator];
8686

87-
/* Under MRC (this file compiles under -fobjc-no-arc per the
88-
* top-level Makefile), 'iv' is a local +1 from alloc+init.
89-
* setContentView: and addSubview: each retained it for their
90-
* own ownership, so at this point its true retain count is
91-
* roughly +3. The two parent-view retains are legitimately
92-
* owned; the +1 from alloc+init is ours to release before
93-
* the local goes out of scope, or it leaks for the app's
94-
* lifetime. 'indicator' is intentionally leaked here - it's
95-
* a file-scope static initialised inside dispatch_once, and
96-
* holding that +1 across the app lifetime is how we keep it
97-
* referenced for the subsequent setDoubleValue / setHidden
98-
* calls outside the block. */
99-
[iv release];
87+
/* This file is compiled under BOTH build systems:
88+
* - qb/top-level Makefile: MRC (not in the per-file ARC
89+
* override list at Makefile:275 alongside metal.o /
90+
* mfi_joypad.o / coreaudio3.o).
91+
* - pkg/apple/*.xcodeproj: ARC, via griffin_objc.m which
92+
* #include's this file into a TU compiled with
93+
* CLANG_ENABLE_OBJC_ARC=YES (pkg/apple/BaseConfig.xcconfig:182).
94+
*
95+
* Under MRC, 'iv' is a local +1 from alloc+init. setContentView:
96+
* and addSubview: each retain their own reference, so those are
97+
* legitimately owned; the +1 from alloc+init is ours to release
98+
* before the local goes out of scope, or it leaks for the app's
99+
* lifetime. Under ARC, the compiler inserts the matching release
100+
* at block scope exit automatically.
101+
*
102+
* RARCH_RELEASE handles both: MRC -> [(x) release], ARC -> ((void)0).
103+
* Raw '[iv release]' is a compile error under ARC
104+
* ('ARC forbids explicit message send of release') which the
105+
* Xcode build would have flagged immediately.
106+
*
107+
* 'indicator' is intentionally kept +1 - it's a file-scope static
108+
* initialised inside dispatch_once, and holding that +1 across
109+
* the app lifetime is how we keep it referenced for the
110+
* subsequent setDoubleValue / setHidden calls outside the
111+
* block. */
112+
RARCH_RELEASE(iv);
100113
});
101114
if (finished)
102115
[indicator setDoubleValue:(double)-1];

0 commit comments

Comments
 (0)