user32: Also disable the DC if the window is destroyed without a ReleaseDC.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-07-18 08:56:59 +02:00
parent 02eda5ccb9
commit 2999123fed
2 changed files with 12 additions and 8 deletions

View File

@ -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 );

View File

@ -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 );