retain exported NSRunningApplication reference to avoid autorelease #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(X-fork clone of koekeishiya#973):
Per discussion/thinking outloud in koekeishiya#967 (koekeishiya#967 (comment) ) with nod from @koekeishiya – Added explicit call to
retain
before returning to C++:https://developer.apple.com/documentation/objectivec/1418956-nsobject/1571946-retain
this seems to be a better way to fix koekeishiya#920 and possibly other crashes in Monterey (and who knows, maybe even earlier); and probably should have been in 8c9bbbe in the first place
I built this (on xorpse/master) and can open and close application without any crash so far on Monterey beta 3 (21A5294g) *knock on wood*
(neither the immediate crashes I was seeing on application launch before, nor the GC-triggered crash as in koekeishiya#923 (comment) )
If this were not needed it would probably introduce a memory leak.
To check I set an lldb breakpoint at https://github.com/koekeishiya/yabai/blob/8777db43b8551e0bc4e5c55d1e15bcbed52501a1/src/workspace.m#L60
Once triggered, I found that:
and
so seems good to me