[vlc-commits] macosx: deinit VLCMain, fix retain cycles for InputManager and playlist

David Fuhrmann git at videolan.org
Tue Aug 11 20:18:12 CEST 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Tue Aug 11 14:10:23 2015 +0200| [39c71bd769443f271471a7c3420265d4b8907b6c] | committer: David Fuhrmann

macosx: deinit VLCMain, fix retain cycles for InputManager and playlist

By deinitializing VLCMain, all connected objects are supposed to
be deallocated automatically. If [VLCMain sharedInstance] is gone,
the intf is deinitalized (this was previously checked with a
nil value of VLCIntf).

Fixes some retain cycles in input manager and playlist code which
prevented these objects to be deinitalized.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=39c71bd769443f271471a7c3420265d4b8907b6c
---

 modules/gui/macosx/InputManager.m |    2 +-
 modules/gui/macosx/PLModel.m      |    4 ++--
 modules/gui/macosx/intf.h         |    2 ++
 modules/gui/macosx/intf.m         |   11 ++++++++---
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/InputManager.m b/modules/gui/macosx/InputManager.m
index e435a58..261abee 100644
--- a/modules/gui/macosx/InputManager.m
+++ b/modules/gui/macosx/InputManager.m
@@ -133,7 +133,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 
 @interface VLCInputManager()
 {
-    VLCMain *o_main;
+    __weak VLCMain *o_main;
 
     input_thread_t *p_current_input;
     dispatch_queue_t informInputChangedQueue;
diff --git a/modules/gui/macosx/PLModel.m b/modules/gui/macosx/PLModel.m
index b31b794..1497c1d 100644
--- a/modules/gui/macosx/PLModel.m
+++ b/modules/gui/macosx/PLModel.m
@@ -106,10 +106,10 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
 @interface PLModel ()
 {
     playlist_t *p_playlist;
-    NSOutlineView *_outlineView;
+    __weak NSOutlineView *_outlineView;
 
     // TODO: for transition
-    VLCPlaylist *_playlist;
+    __weak VLCPlaylist *_playlist;
     NSUInteger _retainedRowSelection;
 }
 @end
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 9ae31fc..7bd4214 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -78,7 +78,9 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
 @property (readonly) VLCVoutWindowController* voutController;
 @property (readonly) BOOL nativeFullscreenMode;
 @property (nonatomic, readwrite) BOOL playlistUpdatedSelectorInQueue;
+
 + (VLCMain *)sharedInstance;
++ (void)killInstance;
 
 - (intf_thread_t *)intf;
 - (void)setIntf:(intf_thread_t *)p_mainintf;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 23d39b8..d91197b 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -97,6 +97,7 @@ void CloseIntf (vlc_object_t *p_this)
     @autoreleasepool {
         msg_Dbg(p_this, "Closing macosx interface");
         [[VLCMain sharedInstance] applicationWillTerminate:nil];
+        [VLCMain killInstance];
     }
 }
 
@@ -174,9 +175,10 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
 #pragma mark -
 #pragma mark Initialization
 
+static VLCMain *sharedInstance = nil;
+
 + (VLCMain *)sharedInstance
 {
-    static VLCMain *sharedInstance = nil;
     static dispatch_once_t pred;
 
     dispatch_once(&pred, ^{
@@ -186,6 +188,11 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     return sharedInstance;
 }
 
++ (void)killInstance
+{
+    sharedInstance = nil;
+}
+
 - (id)init
 {
     self = [super init];
@@ -374,8 +381,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     [[NSUserDefaults standardUserDefaults] synchronize];
 
     o_mainwindow = NULL;
-
-    [self setIntf:nil];
 }
 
 #pragma mark -



More information about the vlc-commits mailing list