[PATCH 1/1] gdiplus: Fix for the "graphics object has no HDC" issue in GdipDrawPath

Fabian Maurer dark.shadow4 at web.de
Tue Aug 30 13:07:05 CDT 2016


Fixes issues with programs trying to render into an image.
If the function is called but no HDC is available, it is temporarily created and the result is merged onto the image.

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/gdiplus/graphics.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 14b9db9..b3bea1a 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3360,6 +3360,7 @@ GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
     INT save_state;
     GpStatus retval;
     HRGN hrgn=NULL;
+    BOOL hdcWasEmpty = FALSE;
 
     TRACE("(%p, %p, %p)\n", graphics, pen, path);
 
@@ -3371,8 +3372,12 @@ GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
 
     if (!graphics->hdc)
     {
-        FIXME("graphics object has no HDC\n");
-        return Ok;
+        TRACE("graphics object has no HDC, creating it temporarily\n");
+
+        if(GdipGetDC(graphics, &graphics->hdc) == Ok)
+            hdcWasEmpty = TRUE;
+        else
+            ERR("HDC could not be created\n");
     }
 
     save_state = prepare_dc(graphics, pen);
@@ -3392,6 +3397,12 @@ end:
     restore_dc(graphics, save_state);
     DeleteObject(hrgn);
 
+    if(hdcWasEmpty)
+    {
+        GdipReleaseDC(graphics, graphics->hdc);
+        graphics->hdc = NULL;
+    }
+
     return retval;
 }
 
-- 
2.9.3




More information about the wine-patches mailing list