From 5e2caa4db96b2da3b78298a304fb0c802fd7e18d Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 20 Feb 2026 23:34:27 +0100 Subject: [PATCH] Remove GC-aware code and fix clip view leak Remove "GC-aware" code as GC is not supported by the OS any longer. Fix leak of wxWindow::m_osxClipView by releasing it after adding it as subview. --- src/osx/cocoa/menu.mm | 8 +------- src/osx/cocoa/window.mm | 11 +++-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 9ab0a7130e..23384d7d47 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -163,10 +163,6 @@ public : } [menu setDelegate:controller]; [m_osxMenu setImplementation:this]; - // gc aware - if ( m_osxMenu ) - CFRetain(m_osxMenu); - [m_osxMenu release]; } virtual ~wxMenuCocoaImpl(); @@ -413,9 +409,7 @@ wxMenuCocoaImpl::~wxMenuCocoaImpl() { [m_osxMenu setDelegate:nil]; [m_osxMenu setImplementation:nil]; - // gc aware - if ( m_osxMenu ) - CFRelease(m_osxMenu); + [m_osxMenu release]; } wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title ) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index fdad8c4901..e7427f0d5e 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2730,11 +2730,6 @@ wxWidgetImpl( peer, flags ) if ( !peer->IsShown() ) SetVisibility(false); - // gc aware handling - if ( m_osxView ) - CFRetain(m_osxView); - [m_osxView release]; - if ( IsUserPane() ) ClipsToBounds(true); } @@ -2771,11 +2766,10 @@ wxWidgetCocoaImpl::~wxWidgetCocoaImpl() if ( sv != nil ) [m_osxView removeFromSuperview]; } - // gc aware handling - if ( m_osxView ) - CFRelease(m_osxView); wxCocoaGestures::EraseForObject(this); + + [m_osxView release]; } void wxWidgetCocoaImpl::BeginNativeKeyDownEvent( NSEvent* event ) @@ -4315,6 +4309,7 @@ void wxWidgetCocoaImpl::UseClippingView() m_osxClipView = [[wxNSClipView alloc] initWithFrame: m_osxView.bounds]; [(NSClipView*)m_osxClipView setDrawsBackground: NO]; [m_osxView addSubview:m_osxClipView]; + [m_osxClipView release]; // add tracking for this clipview as well