Jacek Caban : msctf: Moved thread manager' s UnadviseSink implementation into a more generic helper.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 5 10:29:33 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed May  4 19:40:59 2016 +0200

msctf: Moved thread manager's UnadviseSink implementation into a more generic helper.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msctf/msctf.c          | 19 +++++++++++++++++++
 dlls/msctf/msctf_internal.h |  1 +
 dlls/msctf/threadmgr.c      | 10 +---------
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/dlls/msctf/msctf.c b/dlls/msctf/msctf.c
index 23845d4..81f01dc 100644
--- a/dlls/msctf/msctf.c
+++ b/dlls/msctf/msctf.c
@@ -304,6 +304,25 @@ HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUn
     return S_OK;
 }
 
+static void free_sink(Sink *sink)
+{
+    list_remove(&sink->entry);
+    IUnknown_Release(sink->interfaces.pIUnknown);
+    HeapFree(GetProcessHeap(), 0, sink);
+}
+
+HRESULT unadvise_sink(DWORD cookie)
+{
+    Sink *sink;
+
+    sink = remove_Cookie(cookie);
+    if (!sink)
+        return CONNECT_E_NOCONNECTION;
+
+    free_sink(sink);
+    return S_OK;
+}
+
 /*****************************************************************************
  * Active Text Service Management
  *****************************************************************************/
diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h
index 1f7e7df..fc41de5 100644
--- a/dlls/msctf/msctf_internal.h
+++ b/dlls/msctf/msctf_internal.h
@@ -76,6 +76,7 @@ typedef struct {
 } Sink;
 
 HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie) DECLSPEC_HIDDEN;
+HRESULT unadvise_sink(DWORD cookie) DECLSPEC_HIDDEN;
 
 extern const WCHAR szwSystemTIPKey[] DECLSPEC_HIDDEN;
 extern const WCHAR szwSystemCTFKey[] DECLSPEC_HIDDEN;
diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c
index c6a227c..bface5d 100644
--- a/dlls/msctf/threadmgr.c
+++ b/dlls/msctf/threadmgr.c
@@ -659,21 +659,13 @@ static HRESULT WINAPI ThreadMgrSource_AdviseSink(ITfSource *iface,
 static HRESULT WINAPI ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
 {
     ThreadMgr *This = impl_from_ITfSource(iface);
-    Sink *sink;
 
     TRACE("(%p) %x\n",This,pdwCookie);
 
     if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_TMSINK)
         return E_INVALIDARG;
 
-    sink = remove_Cookie(pdwCookie);
-    if (!sink)
-        return CONNECT_E_NOCONNECTION;
-
-    list_remove(&sink->entry);
-    free_sink(sink);
-
-    return S_OK;
+    return unadvise_sink(pdwCookie);
 }
 
 static const ITfSourceVtbl ThreadMgrSourceVtbl =




More information about the wine-cvs mailing list