wshom.ocx: Properly update typeinfo refcount

Nikolay Sivov nsivov at codeweavers.com
Wed Nov 28 06:01:16 CST 2012


Code keeps one reference per typeinfo, so we need to AddRef only when 
returning it and never release in methods.
-------------- next part --------------
>From e398083e86c51e5a3f067941843352f4f2566cbd Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed, 28 Nov 2012 13:26:26 -0500
Subject: [PATCH 7/7] Properly update typeinfo refcount

---
 dlls/wshom.ocx/shell.c |   41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index 1973e2d..a9e1d01 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -137,8 +137,13 @@ static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT
 static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 {
     WshCollection *This = impl_from_IWshCollection(iface);
+    HRESULT hr;
+
     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
-    return get_typeinfo(IWshCollection_tid, ppTInfo);
+
+    hr = get_typeinfo(IWshCollection_tid, ppTInfo);
+    ITypeInfo_AddRef(*ppTInfo);
+    return hr;
 }
 
 static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames,
@@ -152,10 +157,7 @@ static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID
 
     hr = get_typeinfo(IWshCollection_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
-        ITypeInfo_Release(typeinfo);
-    }
 
     return hr;
 }
@@ -172,12 +174,8 @@ static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdM
 
     hr = get_typeinfo(IWshCollection_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_Invoke(typeinfo, &This->IWshCollection_iface, dispIdMember, wFlags,
                 pDispParams, pVarResult, pExcepInfo, puArgErr);
-        ITypeInfo_Release(typeinfo);
-    }
-
     return hr;
 }
 
@@ -338,8 +336,13 @@ static HRESULT WINAPI WshShortcut_GetTypeInfoCount(IWshShortcut *iface, UINT *pc
 static HRESULT WINAPI WshShortcut_GetTypeInfo(IWshShortcut *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 {
     WshShortcut *This = impl_from_IWshShortcut(iface);
+    HRESULT hr;
+
     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
-    return get_typeinfo(IWshShortcut_tid, ppTInfo);
+
+    hr = get_typeinfo(IWshShortcut_tid, ppTInfo);
+    ITypeInfo_AddRef(*pTInfo);
+    return hr;
 }
 
 static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid, LPOLESTR *rgszNames,
@@ -353,10 +356,7 @@ static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid
 
     hr = get_typeinfo(IWshShortcut_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
-        ITypeInfo_Release(typeinfo);
-    }
 
     return hr;
 }
@@ -373,12 +373,8 @@ static HRESULT WINAPI WshShortcut_Invoke(IWshShortcut *iface, DISPID dispIdMembe
 
     hr = get_typeinfo(IWshShortcut_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_Invoke(typeinfo, &This->IWshShortcut_iface, dispIdMember, wFlags,
                 pDispParams, pVarResult, pExcepInfo, puArgErr);
-        ITypeInfo_Release(typeinfo);
-    }
-
     return hr;
 }
 
@@ -611,8 +607,13 @@ static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinf
 
 static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 {
+    HRESULT hr;
+
     TRACE("(%u %u %p)\n", iTInfo, lcid, ppTInfo);
-    return get_typeinfo(IWshShell3_tid, ppTInfo);
+
+    hr = get_typeinfo(IWshShell3_tid, ppTInfo);
+    ITypeInfo_AddRef(*ppTInfo);
+    return hr;
 }
 
 static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames,
@@ -625,10 +626,7 @@ static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LP
 
     hr = get_typeinfo(IWshShell3_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
-        ITypeInfo_Release(typeinfo);
-    }
 
     return hr;
 }
@@ -644,11 +642,8 @@ static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, R
 
     hr = get_typeinfo(IWshShell3_tid, &typeinfo);
     if(SUCCEEDED(hr))
-    {
         hr = ITypeInfo_Invoke(typeinfo, &WshShell3, dispIdMember, wFlags,
                 pDispParams, pVarResult, pExcepInfo, puArgErr);
-        ITypeInfo_Release(typeinfo);
-    }
 
     return hr;
 }
-- 
1.7.10.4




More information about the wine-patches mailing list