From f6423303066fe812e15ab283f3e1381ced26d8e8 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sat, 23 Dec 2023 19:08:38 +0100 Subject: [PATCH] new: support for releasedWhenClosed in CPWindow --- AppKit/CPView.j | 11 +++++++++++ AppKit/CPWindow/CPWindow.j | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 78cb496f4..df06eb78b 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -44,6 +44,7 @@ @class CPClipView @class CPScrollView @class CALayer +@class CPBinder @global appkit_tag_dom_elements @@ -3732,6 +3733,16 @@ var CPAppearanceVibrantDark = [CPAppearance appearanceNamed:CPAppearanceNameVibr [owners[i] updateTrackingAreas]; } +// needed by CPWindow's releasedWhenClosed property +- (void)_releaseRecursively +{ + [_subviews makeObjectsPerformSelector:@selector(_releaseRecursively)]; + + [self _removeObservers]; + [CPBinder unbindAllForObject:self]; + [self removeFromSuperview]; +} + @end var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 438ec9865..85cf1ea50 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -186,6 +186,7 @@ var CPWindowActionMessageKeys = [ BOOL _constrainsToUsableScreen; unsigned _shadowStyle; BOOL _showsResizeIndicator; + BOOL _releasedWhenClosed @accessors(property=releasedWhenClosed); int _positioningMask; CGRect _positioningScreenRect; @@ -2534,6 +2535,9 @@ CPTexturedBackgroundWindowMask [_parentWindow removeChildWindow:self]; [self _orderOutRecursively:NO]; [self _detachFromChildrenClosing:!_parentWindow]; + + if (_releasedWhenClosed) + [_contentView _releaseRecursively]; } - (void)_detachFromChildrenClosing:(BOOL)shouldCloseChildren