Commit d341b0c3 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Completely free owned DCEs when the corresponding window/class is destroyed.

parent 5f7e4ce6
...@@ -812,7 +812,6 @@ static void test_DeleteDC(void) ...@@ -812,7 +812,6 @@ static void test_DeleteDC(void)
ok(ret, "UnregisterClassA failed\n"); ok(ret, "UnregisterClassA failed\n");
ret = GetObjectType(hdc_test); ret = GetObjectType(hdc_test);
todo_wine
ok(!ret, "GetObjectType should fail for a deleted DC\n"); ok(!ret, "GetObjectType should fail for a deleted DC\n");
/* CS_OWNDC */ /* CS_OWNDC */
......
...@@ -338,16 +338,17 @@ static struct dce *get_window_dce( HWND hwnd ) ...@@ -338,16 +338,17 @@ static struct dce *get_window_dce( HWND hwnd )
*/ */
void free_dce( struct dce *dce, HWND hwnd ) void free_dce( struct dce *dce, HWND hwnd )
{ {
struct dce *dce_to_free = NULL;
USER_Lock(); USER_Lock();
if (dce) if (dce)
{ {
if (!--dce->count) if (!--dce->count)
{ {
/* turn it into a cache entry */
SetHookFlags( dce->hdc, DCHF_RESETDC );
release_dce( dce ); release_dce( dce );
dce->flags |= DCX_CACHE; list_remove( &dce->entry );
dce_to_free = dce;
} }
else if (dce->hwnd == hwnd) else if (dce->hwnd == hwnd)
{ {
...@@ -362,7 +363,7 @@ void free_dce( struct dce *dce, HWND hwnd ) ...@@ -362,7 +363,7 @@ void free_dce( struct dce *dce, HWND hwnd )
LIST_FOR_EACH_ENTRY( dce, &dce_list, struct dce, entry ) LIST_FOR_EACH_ENTRY( dce, &dce_list, struct dce, entry )
{ {
if (dce->hwnd != hwnd) continue; if (dce->hwnd != hwnd) continue;
if (!(dce->flags & DCX_CACHE)) continue; if (!(dce->flags & DCX_CACHE)) break;
if (dce->count) WARN( "GetDC() without ReleaseDC() for window %p\n", hwnd ); if (dce->count) WARN( "GetDC() without ReleaseDC() for window %p\n", hwnd );
dce->count = 0; dce->count = 0;
...@@ -371,6 +372,13 @@ void free_dce( struct dce *dce, HWND hwnd ) ...@@ -371,6 +372,13 @@ void free_dce( struct dce *dce, HWND hwnd )
} }
USER_Unlock(); USER_Unlock();
if (dce_to_free)
{
SetDCHook( dce_to_free->hdc, NULL, 0 );
DeleteDC( dce_to_free->hdc );
HeapFree( GetProcessHeap(), 0, dce_to_free );
}
} }
......
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