Michael Stefaniuc : msctf: Avoid a cast from IEnumTfLanguageProfiles to the COM object.

Alexandre Julliard julliard at winehq.org
Wed Jul 20 10:28:51 CDT 2016


Module: wine
Branch: master
Commit: a944b4eed97d7f69d664aa1f960c5c620908a311
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a944b4eed97d7f69d664aa1f960c5c620908a311

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Tue Jul 19 09:47:24 2016 +0200

msctf: Avoid a cast from IEnumTfLanguageProfiles to the COM object.

Signed-off-by: Michael Stefaniuc <mstefani at redhat.de>
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msctf/inputprocessor.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/dlls/msctf/inputprocessor.c b/dlls/msctf/inputprocessor.c
index fca78e4..fdeba38 100644
--- a/dlls/msctf/inputprocessor.c
+++ b/dlls/msctf/inputprocessor.c
@@ -93,7 +93,7 @@ typedef struct {
 } EnumTfInputProcessorProfiles;
 
 static HRESULT ProfilesEnumGuid_Constructor(IEnumGUID **ppOut);
-static HRESULT EnumTfLanguageProfiles_Constructor(LANGID langid, IEnumTfLanguageProfiles **ppOut);
+static HRESULT EnumTfLanguageProfiles_Constructor(LANGID langid, EnumTfLanguageProfiles **out);
 
 static inline EnumTfInputProcessorProfiles *impl_from_IEnumTfInputProcessorProfiles(IEnumTfInputProcessorProfiles *iface)
 {
@@ -616,12 +616,17 @@ static HRESULT WINAPI InputProcessorProfiles_EnumLanguageProfiles(
         IEnumTfLanguageProfiles **ppEnum)
 {
     InputProcessorProfiles *This = impl_from_ITfInputProcessorProfiles(iface);
+    EnumTfLanguageProfiles *profenum;
+    HRESULT hr;
+
     TRACE("(%p) %x %p\n",This,langid,ppEnum);
 
     if (!ppEnum)
         return E_INVALIDARG;
+    hr = EnumTfLanguageProfiles_Constructor(langid, &profenum);
+    *ppEnum = &profenum->IEnumTfLanguageProfiles_iface;
 
-    return EnumTfLanguageProfiles_Constructor(langid, ppEnum);
+    return hr;
 }
 
 static HRESULT WINAPI InputProcessorProfiles_EnableLanguageProfile(
@@ -1292,16 +1297,16 @@ static HRESULT WINAPI EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles *ifa
     IEnumTfLanguageProfiles **ppenum)
 {
     EnumTfLanguageProfiles *This = impl_from_IEnumTfLanguageProfiles(iface);
+    EnumTfLanguageProfiles *new_This;
     HRESULT res;
 
     TRACE("(%p)\n",This);
 
     if (ppenum == NULL) return E_POINTER;
 
-    res = EnumTfLanguageProfiles_Constructor(This->langid, ppenum);
+    res = EnumTfLanguageProfiles_Constructor(This->langid, &new_This);
     if (SUCCEEDED(res))
     {
-        EnumTfLanguageProfiles *new_This = (EnumTfLanguageProfiles *)*ppenum;
         new_This->tip_index = This->tip_index;
         lstrcpynW(new_This->szwCurrentClsid,This->szwCurrentClsid,39);
 
@@ -1314,6 +1319,7 @@ static HRESULT WINAPI EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles *ifa
             res = RegOpenKeyExW(new_This->tipkey, fullkey, 0, KEY_READ | KEY_WRITE, &This->langkey);
             new_This->lang_index = This->lang_index;
         }
+        *ppenum = &new_This->IEnumTfLanguageProfiles_iface;
     }
     return res;
 }
@@ -1329,7 +1335,7 @@ static const IEnumTfLanguageProfilesVtbl EnumTfLanguageProfilesVtbl =
     EnumTfLanguageProfiles_Skip
 };
 
-static HRESULT EnumTfLanguageProfiles_Constructor(LANGID langid, IEnumTfLanguageProfiles **ppOut)
+static HRESULT EnumTfLanguageProfiles_Constructor(LANGID langid, EnumTfLanguageProfiles **out)
 {
     HRESULT hr;
     EnumTfLanguageProfiles *This;
@@ -1356,7 +1362,7 @@ static HRESULT EnumTfLanguageProfiles_Constructor(LANGID langid, IEnumTfLanguage
         return E_FAIL;
     }
 
-    *ppOut = &This->IEnumTfLanguageProfiles_iface;
-    TRACE("returning %p\n", *ppOut);
+    *out = This;
+    TRACE("returning %p\n", *out);
     return S_OK;
 }




More information about the wine-cvs mailing list