Module: wine Branch: master Commit: d78a58298a8b5574b30c58b5477dae65d5f36713 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d78a58298a8b5574b30c58b547...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Sep 27 21:01:00 2007 +0200
gdi32: Don't hold the GDI lock while calling the driver SelectFont function.
---
dlls/gdi32/font.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 826e331..3b6ec3b 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -588,14 +588,24 @@ HFONT WINAPI CreateFontW( INT height, INT width, INT esc, static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) { HGDIOBJ ret = 0; - DC *dc = DC_GetDCPtr( hdc ); + DC *dc = get_dc_ptr( hdc );
if (!dc) return 0;
+ if (!GDI_inc_ref_count( handle )) + { + release_dc_ptr( dc ); + return 0; + } + if (dc->hFont != handle || dc->gdiFont == NULL) { if(GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_VA_ABLE) + { + FONTOBJ *font = GDI_GetObjPtr( handle, FONT_MAGIC ); /* to grab the GDI lock (FIXME) */ dc->gdiFont = WineEngCreateFontInstance(dc, handle); + if (font) GDI_ReleaseObj( handle ); + } }
if (dc->funcs->pSelectFont) ret = dc->funcs->pSelectFont( dc->physDev, handle, dc->gdiFont ); @@ -603,15 +613,17 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) if (ret && dc->gdiFont) dc->gdiFont = 0;
if (ret == HGDI_ERROR) + { + GDI_dec_ref_count( handle ); ret = 0; /* SelectObject returns 0 on error */ + } else { ret = dc->hFont; dc->hFont = handle; - GDI_inc_ref_count( handle ); GDI_dec_ref_count( ret ); } - DC_ReleaseDCPtr( dc ); + release_dc_ptr( dc ); return ret; }