[3/3] gdiplus: get_log_fontW helper requires a valid graphics object. Take 2.

Dmitry Timoshkov dmitry at baikal.ru
Mon Aug 27 00:12:01 CDT 2012


With GdipFree() replaced by GdipDeletePath() for the path object.
---
 dlls/gdiplus/graphicspath.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 80d9244..16f5e2d 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -946,6 +946,7 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
     LOGFONTW lfw;
     HANDLE hfont;
     HDC dc;
+    GpGraphics *graphics;
     GpPath *backup;
     struct format_string_args args;
     int i;
@@ -966,26 +967,40 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
     scaled_layout_rect.Width = layoutRect->Width * native_height / emSize;
     scaled_layout_rect.Height = layoutRect->Height * native_height / emSize;
 
+    if ((status = GdipClonePath(path, &backup)) != Ok)
+        return status;
+
+    dc = CreateCompatibleDC(0);
+    status = GdipCreateFromHDC(dc, &graphics);
+    if (status != Ok)
+    {
+        DeleteDC(dc);
+        GdipDeletePath(backup);
+        return status;
+    }
+
     status = GdipCreateFont(family, native_height, style, UnitPixel, &font);
     if (status != Ok)
+    {
+        GdipDeleteGraphics(graphics);
+        DeleteDC(dc);
+        GdipDeletePath(backup);
         return status;
+    }
 
-    get_log_fontW(font, NULL, &lfw);
+    get_log_fontW(font, graphics, &lfw);
     GdipDeleteFont(font);
+    GdipDeleteGraphics(graphics);
+
     hfont = CreateFontIndirectW(&lfw);
     if (!hfont)
     {
         WARN("Failed to create font\n");
+        DeleteDC(dc);
+        GdipDeletePath(backup);
         return GenericError;
     }
 
-    if ((status = GdipClonePath(path, &backup)) != Ok)
-    {
-        DeleteObject(hfont);
-        return status;
-    }
-
-    dc = CreateCompatibleDC(0);
     SelectObject(dc, hfont);
 
     GetTextMetricsW(dc, &textmetric);
-- 
1.7.11.5




More information about the wine-patches mailing list