[vlc-commits] vout:win32: don't use the window if we can't store the opaque struct in it

Steve Lhomme git at videolan.org
Tue Apr 2 16:32:55 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Mar 28 10:13:33 2019 +0100| [04be01c8d01206a1318ebc0c864d472fd8a4f9a3] | committer: Steve Lhomme

vout:win32: don't use the window if we can't store the opaque struct in it

Some messages still come before WM_CREATE so we need to call DefWindowProc for
them.

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

 modules/video_output/win32/events.c | 34 +++++++++-------------------------
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index 303f843f35..fb99befa56 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -886,35 +886,19 @@ static void SetAbove( event_thread_t *p_event, bool is_on_top )
 static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
                                          WPARAM wParam, LPARAM lParam )
 {
-    event_thread_t *p_event;
-
     if( message == WM_CREATE )
     {
-        /* Store vd for future use */
-        p_event = (event_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams;
-        SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_event );
-        return TRUE;
-    }
-    else
-    {
-        LONG_PTR p_user_data = GetWindowLongPtr( hwnd, GWLP_USERDATA );
-        p_event = (event_thread_t *)p_user_data;
-        if( !p_event )
-        {
-            /* Hmmm mozilla does manage somehow to save the pointer to our
-             * windowproc and still calls it after the vout has been closed. */
-            return DefWindowProc(hwnd, message, wParam, lParam);
-        }
+        /* Store p_event for future use */
+        CREATESTRUCT *c = (CREATESTRUCT *)lParam;
+        SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)c->lpCreateParams );
+        return 0;
     }
 
-#if 0
-    if( message == WM_SETCURSOR )
-    {
-        msg_Err(p_event->obj, "WM_SETCURSOR: %d (t2)", p_event->is_cursor_hidden);
-        SetCursor( p_event->is_cursor_hidden ? p_event->cursor_empty : p_event->cursor_arrow );
-        return 1;
-    }
-#endif
+    LONG_PTR p_user_data = GetWindowLongPtr( hwnd, GWLP_USERDATA );
+    if( p_user_data == 0 ) /* messages before WM_CREATE */
+        return DefWindowProc(hwnd, message, wParam, lParam);
+    event_thread_t *p_event = (event_thread_t *)p_user_data;
+
     if( message == WM_CAPTURECHANGED )
     {
         for( int button = 0; p_event->button_pressed; button++ )



More information about the vlc-commits mailing list