Module: wine Branch: master Commit: 2999123fedeefe4e41c67216969b512ddd33100b URL: http://source.winehq.org/git/wine.git/?a=commit;h=2999123fedeefe4e41c6721696...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jul 18 08:56:59 2017 +0200
user32: Also disable the DC if the window is destroyed without a ReleaseDC.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/painting.c | 10 +++++++--- dlls/user32/tests/dce.c | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 3c7f220..8448355 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -367,9 +367,13 @@ void free_dce( struct dce *dce, HWND hwnd ) if (dce->hwnd != hwnd) continue; if (!(dce->flags & DCX_CACHE)) break;
- if (dce->count) WARN( "GetDC() without ReleaseDC() for window %p\n", hwnd ); - dce->count = 0; release_dce( dce ); + if (dce->count) + { + WARN( "GetDC() without ReleaseDC() for window %p\n", hwnd ); + dce->count = 0; + SetHookFlags( dce->hdc, DCHF_DISABLEDC ); + } } }
@@ -472,7 +476,7 @@ static INT release_dc( HWND hwnd, HDC hdc, BOOL end_paint )
USER_Lock(); dce = (struct dce *)GetDCHook( hdc, NULL ); - if (dce && dce->count) + if (dce && dce->count && dce->hwnd) { if (!(dce->flags & DCX_NORESETATTRS)) SetHookFlags( dce->hdc, DCHF_RESETDC ); if (end_paint || (dce->flags & DCX_CACHE)) delete_clip_rgn( dce ); diff --git a/dlls/user32/tests/dce.c b/dlls/user32/tests/dce.c index 25b0153..587f36f 100644 --- a/dlls/user32/tests/dce.c +++ b/dlls/user32/tests/dce.c @@ -623,7 +623,7 @@ static void test_destroyed_window(void)
DestroyWindow( hwnd_cache ); rop = GetROP2( dc ); - todo_wine ok( rop == 0, "wrong ROP2 %d\n", rop ); + ok( rop == 0, "wrong ROP2 %d\n", rop ); ok( WindowFromDC( dc ) == 0, "wrong window\n" ); ok( !ReleaseDC( hwnd_cache, dc ), "ReleaseDC succeeded\n" ); dc = GetDC( hwnd_cache ); @@ -654,21 +654,21 @@ static void test_destroyed_window(void) rop = GetROP2( dc ); ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); ok( WindowFromDC( dc ) == 0, "wrong window\n" ); - todo_wine ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" ); + ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" ); dc = GetDC( hwnd_classdc2 ); ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
dc = GetDC( hwnd_classdc ); ok( dc != 0, "Got NULL DC\n" ); rop = GetROP2( dc ); - todo_wine ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" ); DestroyWindow( hwnd_classdc );
rop = GetROP2( dc ); - todo_wine ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); ok( WindowFromDC( dc ) == 0, "wrong window\n" ); - todo_wine ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" ); + ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" ); dc = GetDC( hwnd_classdc ); ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );