]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/events.c
the vout might still run after the playlist termination, so we don't want to use...
[vlc] / modules / video_output / msw / events.c
index 2245bd6de18572312f20a4bdafd1186640475956..5467ca5fdd5a8d5562421fc61a1341dd88ea75bf 100644 (file)
@@ -37,7 +37,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_interface.h>
 #include <vlc_playlist.h>
 #include <vlc_vout.h>
@@ -77,9 +77,9 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args );
 
 static void DirectXPopupMenu( event_thread_t *p_event, bool b_open )
 {
-    playlist_t *p_playlist =
-        vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_playlist != NULL )
+    playlist_t *p_playlist = vlc_object_find( p_event,
+                                             VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist )
     {
         vlc_value_t val;
         val.b_bool = b_open;
@@ -343,9 +343,12 @@ void EventThread( event_thread_t *p_event )
 #ifdef UNICODE
             {
                 wchar_t *psz_title = malloc( strlen(val.psz_string) * 2 + 2 );
-                mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
-                psz_title[strlen(val.psz_string)] = 0;
-                free( val.psz_string ); val.psz_string = (char *)psz_title;
+                if( psz_title )
+                {
+                    mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
+                    psz_title[strlen(val.psz_string)] = 0;
+                    free( val.psz_string ); val.psz_string = (char *)psz_title;
+                }
             }
 #endif
 
@@ -867,16 +870,13 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
     /* the user wants to close the window */
     case WM_CLOSE:
     {
-        playlist_t * p_playlist =
-            (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
-                                           FIND_ANYWHERE );
-        if( p_playlist == NULL )
+        playlist_t * p_playlist = vlc_object_find( p_vout,
+                                                  VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+        if( p_playlist )
         {
-            return 0;
+            playlist_Stop( p_playlist );
+            vlc_object_release( p_playlist );
         }
-
-        playlist_Stop( p_playlist );
-        vlc_object_release( p_playlist );
         return 0;
     }