vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrm...@videolan.org> | Mon Mar 29 10:54:19 2021 +0200| [53359e6f9bbcc101f84935d272b4be5b6bd1fb3b] | committer: David Fuhrmann
macosx: Fix crash on exit related to PXSourceList The delegate object (aka VLCMainWindow) is sometimes not valid anymore when the destructor of PXSourceListDelegateDataSourceProxy is called. Also, VLCMainWindow removes all observers from the notification center in its own dealloc method already. This should fix the majority of current on-exit related crashes on macOS. close #25403 > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=53359e6f9bbcc101f84935d272b4be5b6bd1fb3b --- .../PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.h | 4 ++-- .../PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.m | 6 ++++-- modules/gui/macosx/VLCMainWindow.m | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.h b/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.h index 3ea5605058..2bf8930597 100755 --- a/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.h +++ b/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.h @@ -13,8 +13,8 @@ @interface PXSourceListDelegateDataSourceProxy : NSProxy <NSOutlineViewDelegate, NSOutlineViewDataSource, PXSourceListDelegate, PXSourceListDataSource> @property (weak, nonatomic) PXSourceList *sourceList; -@property (unsafe_unretained, nonatomic) id <PXSourceListDelegate> delegate; -@property (unsafe_unretained, nonatomic) id <PXSourceListDataSource> dataSource; +@property (weak, nonatomic) id <PXSourceListDelegate> delegate; +@property (weak, nonatomic) id <PXSourceListDataSource> dataSource; - (id)initWithSourceList:(PXSourceList *)sourceList; diff --git a/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.m b/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.m index c5e2e8e286..182de2c8bd 100755 --- a/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.m +++ b/modules/gui/macosx/PXSourceList/Internal/PXSourceListDelegateDataSourceProxy.m @@ -61,8 +61,10 @@ static NSArray * __fastPathForwardingDataSourceMethods = nil; - (void)dealloc { - //Unregister the delegate from receiving notifications - [[NSNotificationCenter defaultCenter] removeObserver:self.delegate name:nil object:self.sourceList]; + // Unregister the delegate from receiving notifications + if (self.delegate) { + [[NSNotificationCenter defaultCenter] removeObserver:self.delegate name:nil object:self.sourceList]; + } } #pragma mark - Accessors diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m index 84d33a5ed4..2515ee132e 100644 --- a/modules/gui/macosx/VLCMainWindow.m +++ b/modules/gui/macosx/VLCMainWindow.m @@ -136,6 +136,8 @@ static const float f_min_window_height = 307.; - (void)dealloc { + msg_Dbg(getIntf(), "Deinitializing VLCMainWindow object"); + [[NSNotificationCenter defaultCenter] removeObserver: self]; if (@available(macOS 10_14, *)) { [[NSApplication sharedApplication] removeObserver:self forKeyPath:@"effectiveAppearance"]; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits