[PATCH V2 2/2] gdiplus: keep temporary dc from being released.

Changping Yu dead.ash at hotmail.com
Mon Jun 22 07:02:56 CDT 2020


-------------- next part --------------
>From 0e5574a6b90c2336c7b200793ed21e5845c375a5 Mon Sep 17 00:00:00 2001
From: Changping Yu <dead.ash at hotmail.com>
Date: Mon, 22 Jun 2020 19:55:12 +0800
Subject: [PATCH V2 2/2] gdiplus: keep temporary dc from being released.

v2: add more tests.

When quick call GdipGetDC then call GdipReleaseDC, now call
GdipCreateFontFromLogfontA need the front dc, but wine will
delete the temporary dc.

Signed-off-by: Changping Yu <dead.ash at hotmail.com>
---
 dlls/gdiplus/graphics.c       | 8 ++++++--
 dlls/gdiplus/tests/graphics.c | 1 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 6619be9b58..3b36c50346 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2548,6 +2548,9 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
 
     DeleteObject(graphics->gdi_clip);
 
+    if(graphics->temp_hdc)
+        DeleteDC(graphics->temp_hdc);
+
     /* Native returns ObjectBusy on the second free, instead of crashing as we'd
      * do otherwise, but we can't have that in the test suite because it means
      * accessing freed memory. */
@@ -6675,6 +6678,9 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
         SelectObject(temp_hdc, hbitmap);
 
         graphics->temp_hbitmap = hbitmap;
+        if(graphics->temp_hdc)
+            DeleteDC(graphics->temp_hdc);
+
         *hdc = graphics->temp_hdc = temp_hdc;
     }
     else
@@ -6723,9 +6729,7 @@ GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
             graphics->temp_hbitmap_width * 4, PixelFormat32bppARGB);
 
         /* Clean up. */
-        DeleteDC(graphics->temp_hdc);
         DeleteObject(graphics->temp_hbitmap);
-        graphics->temp_hdc = NULL;
         graphics->temp_hbitmap = NULL;
     }
     else if (hdc != graphics->hdc)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 2b47171d96..63b8d4c738 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -1728,7 +1728,6 @@ static void test_Get_Release_DC(void)
     expect(Ok, status);
     /* try to use temp dc released on image */
     status = GdipCreateFontFromLogfontA(retdc, &logfont, &fnt);
-    todo_wine
     expect(Ok, status);
 
     status = GdipDisposeImage((GpImage*)bm);
-- 
2.26.2.windows.1



More information about the wine-devel mailing list