From: Miklós Máté Subject: [PATCH v2] winex11: fix destroying of top-level windows Message-Id: <1466454436-31552-1-git-send-email-mtmkls@gmail.com> Date: Mon, 20 Jun 2016 22:27:16 +0200 Fixes https://bugs.winehq.org/show_bug.cgi?id=40767 v2: move glXDestroyWindow before XDestroyWindow Signed-off-by: Miklós Máté --- dlls/winex11.drv/opengl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index d89a193..3c4445f 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1314,6 +1314,9 @@ static void free_gl_drawable( struct gl_drawable *gl ) { switch (gl->type) { + case DC_GL_WINDOW: + pglXDestroyWindow( gdi_display, gl->drawable ); + break; case DC_GL_CHILD_WIN: pglXDestroyWindow( gdi_display, gl->drawable ); XDestroyWindow( gdi_display, gl->window ); @@ -1435,6 +1438,14 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format ) gl->rect.right = min( max( 1, gl->rect.right ), 65535 ); gl->rect.bottom = min( max( 1, gl->rect.bottom ), 65535 ); + EnterCriticalSection( &context_section ); + if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&prev )) + { + gl->swap_interval = prev->swap_interval; + free_gl_drawable( prev ); + } + LeaveCriticalSection( &context_section ); + if (!create_gl_drawable( hwnd, gl )) { XFree( gl->visual ); @@ -1448,11 +1459,6 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format ) XFlush( gdi_display ); EnterCriticalSection( &context_section ); - if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&prev )) - { - gl->swap_interval = prev->swap_interval; - free_gl_drawable( prev ); - } XSaveContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char *)gl ); LeaveCriticalSection( &context_section ); -- 2.8.1