dwrite: Correct reference count behavior for font face interface

Nikolay Sivov nsivov at codeweavers.com
Mon Oct 15 06:43:23 CDT 2012


Correct reference count behavior for font face interface
-------------- next part --------------
>From 2c1991a7deec09097ba9dc88926f1a28e714ef45 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat, 13 Oct 2012 01:22:05 -0400
Subject: [PATCH 1/6] Correct reference count behavior for font face interface

---
 dlls/dwrite/font.c       |    3 +--
 dlls/dwrite/tests/font.c |    6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index e7beee5..d145df0 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -352,6 +352,7 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont *iface)
 
     if (!ref)
     {
+        if (This->face) IDWriteFontFace_Release(This->face);
         IDWriteFontFamily_Release(This->family);
         heap_free(This);
     }
@@ -442,8 +443,6 @@ static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont *iface, IDWriteFontF
     {
         HRESULT hr = create_fontface(&This->face);
         if (FAILED(hr)) return hr;
-        *face = This->face;
-        return hr;
     }
 
     *face = This->face;
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 70c714c..83c19da 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -433,17 +433,17 @@ if (0) /* crashes on native */
     hr = IDWriteFont_CreateFontFace(font, &fontface);
     ok(hr == S_OK, "got 0x%08x\n", hr);
     EXPECT_REF(font, 1);
-    EXPECT_REF(fontface, 1);
+    EXPECT_REF(fontface, 2);
 
     hr = IDWriteFont_CreateFontFace(font, &fontface2);
     ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
-    EXPECT_REF(fontface, 2);
+    EXPECT_REF(fontface, 3);
     EXPECT_REF(font, 1);
 
     IDWriteFontFace_AddRef(fontface);
     EXPECT_REF(font, 1);
-    EXPECT_REF(fontface, 3);
+    EXPECT_REF(fontface, 4);
     IDWriteFontFace_Release(fontface);
     IDWriteFontFace_Release(fontface);
 
-- 
1.7.10.4



More information about the wine-patches mailing list