vlc/vlc-2.0 | branch: master | David Fuhrmann <david.fuhrm...@googlemail.com> | 
Sat Mar  3 17:01:08 2012 +0100| [d205a7890f815e3d555d7d5cadadb66ed3300b18] | 
committer: Felix Paul Kühne

macosx: fix crash on exit in concunction with InputEvent

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

Signed-off-by: Felix Paul Kühne <fkue...@videolan.org>
(cherry picked from commit 53f6bc016209b67a56c2bbecf03ae05c42b7f5ed)

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

 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 128ea33..f94c77b 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;
-
-    p_input = playlist_CurrentInput( pl_Get(VLCIntf) );
-    if( p_input && !( p_input->b_dead || !vlc_object_alive(p_input) ) )
+    if( p_current_input && ( p_current_input->b_dead || !vlc_object_alive( 
p_current_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
+        var_DelCallback( p_current_input, "intf-event", InputEvent, [VLCMain 
sharedInstance] );
+        vlc_object_release( p_current_input );
+        p_current_input = NULL;
+
         [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];

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to