Commit 2999123f authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 02eda5cc
......@@ -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 );
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment