]> git.sesse.net Git - vlc/commitdiff
Don't leak a HICON
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 1 Sep 2011 15:36:02 +0000 (17:36 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 5 Sep 2011 10:27:26 +0000 (12:27 +0200)
modules/video_output/msw/events.c

index 35aa0cb6445257e97898173740013bc85c0a2171..7c7aef0aaa9c2cd3da07eb22caca133672d031fb 100644 (file)
@@ -125,6 +125,8 @@ struct event_thread_t
     video_format_t       source;
     vout_display_place_t place;
 
+    HICON vlc_icon;
+
     bool has_moved;
 };
 
@@ -488,7 +490,6 @@ static int DirectXCreateWindow( event_thread_t *p_event )
     HMENU      hMenu;
     RECT       rect_window;
     WNDCLASS   wc;                            /* window class components */
-    HICON      vlc_icon;
     char       vlc_path[MAX_PATH+1];
     int        i_style, i_stylex;
 
@@ -527,11 +528,11 @@ static int DirectXCreateWindow( event_thread_t *p_event )
 #endif
 
     /* Get the Icon from the main app */
-    vlc_icon = NULL;
+    p_event->vlc_icon = NULL;
 #ifndef UNDER_CE
     if( GetModuleFileName( NULL, vlc_path, MAX_PATH ) )
     {
-        vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
+        p_event->vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
     }
 #endif
 
@@ -541,7 +542,7 @@ static int DirectXCreateWindow( event_thread_t *p_event )
     wc.cbClsExtra    = 0;                         /* no extra class data */
     wc.cbWndExtra    = 0;                        /* no extra window data */
     wc.hInstance     = hInstance;                            /* instance */
-    wc.hIcon         = vlc_icon;                /* load the vlc big icon */
+    wc.hIcon         = p_event->vlc_icon;       /* load the vlc big icon */
     wc.hCursor       = p_event->is_cursor_hidden ? p_event->cursor_empty :
                                                    p_event->cursor_arrow;
     wc.hbrBackground = GetStockObject(BLACK_BRUSH);  /* background color */
@@ -551,8 +552,8 @@ static int DirectXCreateWindow( event_thread_t *p_event )
     /* Register the window class */
     if( !RegisterClass(&wc) )
     {
-        if( vlc_icon )
-            DestroyIcon( vlc_icon );
+        if( p_event->vlc_icon )
+            DestroyIcon( p_event->vlc_icon );
 
         msg_Err( vd, "DirectXCreateWindow RegisterClass FAILED (err=%lu)", GetLastError() );
         return VLC_EGENERIC;
@@ -707,6 +708,9 @@ static void DirectXCloseWindow( event_thread_t *p_event )
         vout_display_DeleteWindow( vd, p_event->parent_window );
     p_event->hwnd = NULL;
 
+    if( p_event->vlc_icon )
+        DestroyIcon( p_event->vlc_icon );
+
     HINSTANCE hInstance = GetModuleHandle(NULL);
     UnregisterClass( p_event->class_video, hInstance );
     UnregisterClass( p_event->class_main, hInstance );