]> git.sesse.net Git - vlc/commitdiff
macosx/voutgl.m: fixed another crash (hopefully the last one).
authorEric Petit <titer@videolan.org>
Fri, 18 Feb 2005 15:11:21 +0000 (15:11 +0000)
committerEric Petit <titer@videolan.org>
Fri, 18 Feb 2005 15:11:21 +0000 (15:11 +0000)
   Looks like OS X delayed the window destruction, causing the crash
   since reshape tries to use p_vout after it's been freed.

modules/gui/macosx/voutgl.m

index 5eded56574f44d55f769a5a031668c75e0c40332..c3c5a5566eb39c3b34295fd2a240bbb9142b9f9b 100644 (file)
@@ -121,15 +121,23 @@ int E_(OpenVideoGL)  ( vlc_object_t * p_this )
     return VLC_SUCCESS;
 }
 
-int E_(CloseVideoGL) ( vlc_object_t * p_this )
+void E_(CloseVideoGL) ( vlc_object_t * p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *) p_this;
     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
 
+    /* Remove the GLView from the window, because we are not sure OS X
+       will actually close the window right away. When it doesn't,
+       VLCGLView's reshape is called while p_vout and p_vout->p_sys
+       aren't valid anymore and crashes. */
+    [p_vout->p_sys->o_window setContentView: NULL];
+
+    /* Close the window */
     [p_vout->p_sys->o_window close];
 
+    /* Clean up */
     [o_pool release];
-    return VLC_SUCCESS;
+    free( p_vout->p_sys );
 }
 
 static int Init( vout_thread_t * p_vout )
@@ -263,7 +271,7 @@ static void Swap( vout_thread_t * p_vout )
     return self;
 }
 
-- (void)reshape
+- (void) reshape
 {
     int x, y;
     NSRect bounds = [self bounds];