Module: wine Branch: master Commit: d9d7e8f39228a9c5ae6bce2a90641f45a8f7e404 URL: https://gitlab.winehq.org/wine/wine/-/commit/d9d7e8f39228a9c5ae6bce2a90641f4...
Author: Esme Povirk esme@codeweavers.com Date: Sat May 4 20:24:18 2024 +0000
gdiplus: Bracket HDC use in GdipDrawString.
---
dlls/gdiplus/graphics.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index b93b3f0c277..c089a984db7 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5987,6 +5987,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, GDIPCONST GpBrush *brush) { + GpStatus status; HRGN rgn = NULL; HFONT gdifont; GpPointF rectcpy[4]; @@ -6005,9 +6006,11 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string if(!graphics || !string || !font || !brush || !rect) return InvalidParameter;
- if(graphics->hdc) + if(has_gdi_dc(graphics)) { - hdc = graphics->hdc; + status = gdi_dc_acquire(graphics, &hdc); + if (status != Ok) + return status; } else { @@ -6097,7 +6100,10 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
RestoreDC(hdc, save_state);
- DeleteDC(temp_hdc); + if (temp_hdc) + DeleteDC(temp_hdc); + else + gdi_dc_release(graphics, hdc);
return Ok; }