[vlc-devel] [PATCH 2/2] macosx: fix crash on exit in concunction with InputEvent

David Fuhrmann david.fuhrmann at googlemail.com
Sat Mar 3 17:01:08 CET 2012


Crash logs are in trac.
For each input thread the callback for "intf-event" was registered
at least twice, and never deleted correctly.
Therefore this patch makes sure that we add the callback only once,
and also properly delete the old one when the input changed.

should close #6207, refs #6252
---
 modules/gui/macosx/intf.h |    1 +
 modules/gui/macosx/intf.m |   39 +++++++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 9f15c9f..a80664a 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -89,6 +89,7 @@ struct intf_sys_t
 @interface VLCMain : NSObject <NSWindowDelegate>
 {
     intf_thread_t *p_intf;      /* The main intf object */
+    input_thread_t *p_current_input;
     id o_mainmenu;              /* VLCMainMenu */
     id o_prefs;                 /* VLCPrefs       */
     id o_sprefs;                /* VLCSimplePrefs */
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 9349fc4..2817ac2 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -514,6 +514,7 @@ static VLCMain *_o_sharedMainInstance = nil;
         _o_sharedMainInstance = [super init];
 
     p_intf = NULL;
+    p_current_input = NULL;
 
     o_msg_lock = [[NSLock alloc] init];
     o_msg_arr = [[NSMutableArray arrayWithCapacity: 600] retain];
@@ -732,11 +733,11 @@ static VLCMain *_o_sharedMainInstance = nil;
     var_DelCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self);
     var_DelCallback(p_intf->p_libvlc, "intf-show", ShowController, self);
 
-    input_thread_t * p_input = playlist_CurrentInput( p_playlist );
-    if( p_input )
+    if( p_current_input )
     {
-        var_DelCallback( p_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
-        vlc_object_release( p_input );
+        var_DelCallback( p_current_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
+        vlc_object_release( p_current_input );
+        p_current_input = NULL;
     }
 
     /* remove global observer watching for vout device changes correctly */
@@ -1394,21 +1395,27 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 
 - (void)PlaylistItemChanged
 {
-    input_thread_t * p_input;
+    if( p_current_input && ( p_current_input->b_dead || !vlc_object_alive( p_current_input ) ))
+    {        
+        var_DelCallback( p_current_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
+        vlc_object_release( p_current_input );
+        p_current_input = NULL;
 
-    p_input = playlist_CurrentInput( pl_Get(VLCIntf) );
-    if( p_input && !( p_input->b_dead || !vlc_object_alive(p_input) ) )
-    {
-        var_AddCallback( p_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
-        [o_mainmenu setRateControlsEnabled: YES];
-        if ([self activeVideoPlayback] && [[o_mainwindow videoView] isHidden])
-            [o_mainwindow performSelectorOnMainThread:@selector(togglePlaylist:) withObject: nil waitUntilDone:NO];
-    }
-    else
         [o_mainmenu setRateControlsEnabled: NO];
+    }
+    else if( !p_current_input ) 
+    {
+        // object is hold here and released then it is dead
+        p_current_input = playlist_CurrentInput( pl_Get( VLCIntf ));
+        if( p_current_input )
+        {
+            var_AddCallback( p_current_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
 
-    if (p_input)
-        vlc_object_release( p_input );
+            [o_mainmenu setRateControlsEnabled: YES];
+            if ( [self activeVideoPlayback] && [[o_mainwindow videoView] isHidden] )
+                [o_mainwindow performSelectorOnMainThread:@selector(togglePlaylist:) withObject: nil waitUntilDone:NO];
+        }
+    }
 
     [o_playlist updateRowSelection];
     [o_mainwindow updateWindow];
-- 
1.7.7.5 (Apple Git-26)




More information about the vlc-devel mailing list