diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 3648f64b8c..2032dfaf15 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -103,9 +103,9 @@ DC *alloc_dc_ptr( const DC_FUNCTIONS *funcs, WORD magic ) dc->hMetaRgn = 0; dc->hMetaClipRgn = 0; dc->hVisRgn = 0; - dc->hPen = GetStockObject( BLACK_PEN ); - dc->hBrush = GetStockObject( WHITE_BRUSH ); - dc->hFont = GetStockObject( SYSTEM_FONT ); + dc->hPen = GDI_inc_ref_count( GetStockObject( BLACK_PEN )); + dc->hBrush = GDI_inc_ref_count( GetStockObject( WHITE_BRUSH )); + dc->hFont = GDI_inc_ref_count( GetStockObject( SYSTEM_FONT )); dc->hBitmap = 0; dc->hDevice = 0; dc->hPalette = GetStockObject( DEFAULT_PALETTE ); @@ -680,7 +680,7 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, if (!(dc = alloc_dc_ptr( funcs, OBJ_DC ))) goto error; hdc = dc->hSelf; - dc->hBitmap = GetStockObject( DEFAULT_BITMAP ); + dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP )); if (!(dc->hVisRgn = CreateRectRgn( 0, 0, 1, 1 ))) goto error; TRACE("(driver=%s, device=%s, output=%s): returning %p\n", @@ -797,7 +797,7 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) TRACE("(%p): returning %p\n", hdc, dc->hSelf ); - dc->hBitmap = GetStockObject( DEFAULT_BITMAP ); + dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP )); if (!(dc->hVisRgn = CreateRectRgn( 0, 0, 1, 1 ))) goto error; /* default bitmap is 1x1 */ /* Copy the driver-specific physical device info into diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 87d4ec0dd1..f4c2d029b3 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -442,7 +442,7 @@ extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN; extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN; extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN; extern void GDI_CheckNotLock(void) DECLSPEC_HIDDEN; -extern BOOL GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN; +extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN; extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN; extern BOOL GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN; extern BOOL GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 55577872e3..b4ca4d9bbd 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -522,7 +522,7 @@ static DWORD get_dpi( void ) * * Increment the reference count of a GDI object. */ -BOOL GDI_inc_ref_count( HGDIOBJ handle ) +HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) { GDIOBJHDR *header; @@ -531,7 +531,9 @@ BOOL GDI_inc_ref_count( HGDIOBJ handle ) header->dwCount++; GDI_ReleaseObj( handle ); } - return header != NULL; + else handle = 0; + + return handle; }