From c5dad4998c9db06200fe3b57995f832b486ea67c Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Mon, 28 Mar 2011 20:52:27 +0000 Subject: [PATCH] [USER32] Fix a bug causing "Attempted to lock object, wrong reuse counter" messages when CMD was started in LiveCD. Once got desktop HDC was used in different threads. When thread, which created handle terminated, DC handle was removed and next calls to CreateIcon* API was using invalid hDC. svn path=/trunk/; revision=51184 --- reactos/dll/win32/user32/windows/cursoricon.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/user32/windows/cursoricon.c b/reactos/dll/win32/user32/windows/cursoricon.c index 32b0ffde97a..e3c5ca13b29 100644 --- a/reactos/dll/win32/user32/windows/cursoricon.c +++ b/reactos/dll/win32/user32/windows/cursoricon.c @@ -458,16 +458,10 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, void *color_bits, *mask_bits; BOOL ret = FALSE; HDC hdc = 0; - static HDC hScreenDC = 0; if (!(info = HeapAlloc( GetProcessHeap(), 0, max( size, FIELD_OFFSET( BITMAPINFO, bmiColors[2] ))))) return FALSE; - if(!hScreenDC) - { - hScreenDC = GetDC(0); - if(!hScreenDC) goto done; - } - if (!(hdc = CreateCompatibleDC(hScreenDC))) goto done; + if (!(hdc = CreateCompatibleDC(NULL))) goto done; memcpy( info, bmi, size ); info->bmiHeader.biHeight /= 2; @@ -491,8 +485,8 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, else { if (!(*mask = CreateBitmap( width, height, 1, 1, NULL ))) goto done; - if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hScreenDC, PLANES), - GetDeviceCaps(hScreenDC, BITSPIXEL), NULL ))) + if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hdc, PLANES), + GetDeviceCaps(hdc, BITSPIXEL), NULL ))) { DeleteObject( *mask ); goto done;