Robert Shearman : oleaut: Fix standard font cloning.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 24 04:48:09 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 7fbca4c1117549553c289e4cfac54b4e63d93c42
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=7fbca4c1117549553c289e4cfac54b4e63d93c42

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Feb 23 19:01:02 2006 +0000

oleaut: Fix standard font cloning.
Create new empty connection points on clone of the standard Font
(based on a patch by Alex Villacís Lasso).

---

 dlls/oleaut32/olefont.c       |   11 +++++++++++
 dlls/oleaut32/tests/olefont.c |   17 ++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c
index b213f50..a9110e7 100644
--- a/dlls/oleaut32/olefont.c
+++ b/dlls/oleaut32/olefont.c
@@ -1109,6 +1109,17 @@ static HRESULT WINAPI OLEFontImpl_Clone(
 
   newObject->gdiFont = CreateFontIndirectW(&logFont);
 
+  /* create new connection points */
+  newObject->pPropertyNotifyCP = NULL;
+  newObject->pFontEventsCP = NULL;
+  CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pPropertyNotifyCP);
+  CreateConnectionPoint((IUnknown*)newObject, &IID_IFontEventsDisp, &newObject->pFontEventsCP);
+
+  if (!newObject->pPropertyNotifyCP || !newObject->pFontEventsCP)
+  {
+    OLEFontImpl_Destroy(newObject);
+    return E_OUTOFMEMORY;
+  }
 
   /* The cloned object starts with a reference count of 1 */
   newObject->ref          = 1;
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c
index 5906749..1fb1596 100644
--- a/dlls/oleaut32/tests/olefont.c
+++ b/dlls/oleaut32/tests/olefont.c
@@ -206,7 +206,7 @@ static ULONG WINAPI FontEventsDisp_Relea
     return 1;
 }
 
-static BOOL fonteventsdisp_invoke_called = FALSE;
+static int fonteventsdisp_invoke_called = 0;
 
 static HRESULT WINAPI FontEventsDisp_Invoke(
         IFontEventsDisp __RPC_FAR * iface,
@@ -226,7 +226,7 @@ static HRESULT WINAPI FontEventsDisp_Inv
     ok(V_VT(&pDispParams->rgvarg[0]) == VT_BSTR, "VT of first param should have been VT_BSTR instead of %d\n", V_VT(&pDispParams->rgvarg[0]));
     ok(!lstrcmpW(V_BSTR(&pDispParams->rgvarg[0]), wszBold), "String in first param should have been \"Bold\"\n");
 
-    fonteventsdisp_invoke_called = TRUE;
+    fonteventsdisp_invoke_called++;
     return S_OK;
 }
 
@@ -246,6 +246,7 @@ static IFontEventsDisp FontEventsDisp = 
 static void test_font_events_disp(void)
 {
     IFont *pFont;
+    IFont *pFont2;
     IConnectionPointContainer *pCPC;
     IConnectionPoint *pCP;
     FONTDESC fontdesc;
@@ -279,9 +280,19 @@ static void test_font_events_disp(void)
     hr = IFont_put_Bold(pFont, TRUE);
     ok_ole_success(hr, "IFont_put_Bold");
 
-    ok(fonteventsdisp_invoke_called, "IFontEventDisp::Invoke wasn't called\n");
+    ok(fonteventsdisp_invoke_called == 1, "IFontEventDisp::Invoke wasn't called once\n");
 
+    hr = IFont_Clone(pFont, &pFont2);
+    ok_ole_success(hr, "IFont_Clone");
     IFont_Release(pFont);
+
+    hr = IFont_put_Bold(pFont2, TRUE);
+    ok_ole_success(hr, "IFont_put_Bold");
+
+    /* this test shows that the notification routine isn't called again */
+    ok(fonteventsdisp_invoke_called == 1, "IFontEventDisp::Invoke wasn't called once\n");
+
+    IFont_Release(pFont2);
 }
 
 START_TEST(olefont)




More information about the wine-cvs mailing list