macosx: Fix crash when deinitializing PLModel
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Tue, 11 Aug 2015 17:14:59 +0000 (19:14 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Tue, 11 Aug 2015 18:17:57 +0000 (20:17 +0200)
Only self should be used as callback parameters. Otherwise,
depending on the destruction order the original object might be
deinitialized already.

modules/gui/macosx/PLModel.m

index 1497c1d..7478fc3 100644 (file)
@@ -93,8 +93,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
 {
     @autoreleasepool {
         dispatch_async(dispatch_get_main_queue(), ^{
-            VLCMainWindow *mainWindow = (__bridge VLCMainWindow*)param;
-            [mainWindow updateVolumeSlider];
+            [[[VLCMain sharedInstance] mainWindow] updateVolumeSlider];
         });
 
         return VLC_SUCCESS;
@@ -133,8 +132,8 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
         var_AddCallback(p_playlist, "random", PlaybackModeUpdated, (__bridge void *)self);
         var_AddCallback(p_playlist, "repeat", PlaybackModeUpdated, (__bridge void *)self);
         var_AddCallback(p_playlist, "loop", PlaybackModeUpdated, (__bridge void *)self);
-        var_AddCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)[[VLCMain sharedInstance] mainWindow]);
-        var_AddCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)[[VLCMain sharedInstance] mainWindow]);
+        var_AddCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)self);
+        var_AddCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)self);
 
         PL_LOCK;
         _rootItem = [[PLItem alloc] initWithPlaylistItem:root];
@@ -153,8 +152,8 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
     var_DelCallback(p_playlist, "random", PlaybackModeUpdated, (__bridge void *)self);
     var_DelCallback(p_playlist, "repeat", PlaybackModeUpdated, (__bridge void *)self);
     var_DelCallback(p_playlist, "loop", PlaybackModeUpdated, (__bridge void *)self);
-    var_DelCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)[[VLCMain sharedInstance] mainWindow]);
-    var_DelCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)[[VLCMain sharedInstance] mainWindow]);
+    var_DelCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)self);
+    var_DelCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)self);
 }
 
 - (void)changeRootItem:(playlist_item_t *)p_root;