Commit e9279a8
committed
OSX/MACOS: Plug MRR leaks in RetroArch_OSX ivar lifetimes
Follow-up to 9743d1e. Audit of the other unretained id ivars in
ui_cocoa.m surfaced three smaller lifetime bugs. Unlike the
_sleepActivity crash they do not dangle - the referenced objects
are kept alive by a second owner (NSWindow.contentView, the
_listener delegate slot, g_instance) - so they manifest as leaks
rather than EXC_BAD_ACCESS, but they are strictly incorrect under
MRR and worth cleaning up while the area is warm.
- _renderView: normalise the three -setViewType: paths to a +1
ownership invariant. [MetalView new] already hands us +1, so
the Metal path is unchanged. The VULKAN and OPENGL paths get
an explicit RARCH_RETAIN around [CocoaView get], which returns
an unretained pointer to a singleton. The teardown block then
gets a matching RARCH_RELEASE(_renderView) before nilling, so
a view-type switch away from Metal no longer leaks the
MetalView and switches between the singleton-based types no
longer over-release.
- CAMetalLayer: the VULKAN path was +alloc/+init-ing a layer and
handing it to _renderView.layer (a strong reference, so the
view took its own retain) without balancing our +1. Autorelease
the local so the layer is freed once the view drops it.
- _listener (HAVE_COCOA_METAL only): created with +new (+1) in
-applicationDidFinishLaunching: and wired up as the window's
delegate and nextResponder - both of which are non-retaining
relationships, so the ivar was the sole owner. Release it in
-dealloc (MRR branch) so the listener is not leaked at shutdown.
No behavioural change under ARC, where strong ivars already track
these retains automatically and the RARCH_RETAIN / RARCH_RELEASE
macros expand to no-ops. The pre-10.9 SDK compatibility guard
stays scoped to the App Nap code path from 9743d1e - none of the
APIs touched here are version-sensitive.1 parent 9743d1e commit e9279a8
1 file changed
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
633 | 644 | | |
634 | 645 | | |
635 | 646 | | |
| |||
719 | 730 | | |
720 | 731 | | |
721 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
722 | 740 | | |
723 | 741 | | |
724 | 742 | | |
725 | 743 | | |
726 | 744 | | |
727 | 745 | | |
728 | 746 | | |
729 | | - | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
730 | 751 | | |
731 | 752 | | |
732 | 753 | | |
733 | 754 | | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
734 | 758 | | |
| 759 | + | |
735 | 760 | | |
736 | 761 | | |
737 | 762 | | |
738 | 763 | | |
739 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
740 | 768 | | |
741 | 769 | | |
742 | 770 | | |
743 | 771 | | |
744 | 772 | | |
745 | 773 | | |
746 | 774 | | |
747 | | - | |
| 775 | + | |
| 776 | + | |
748 | 777 | | |
749 | 778 | | |
750 | 779 | | |
| |||
0 commit comments