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

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-05-04 19:40:59 +02:00 committed by Alexandre Julliard
parent c0efd074b2
commit 0374ee290d
3 changed files with 21 additions and 9 deletions

View File

@ -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
*****************************************************************************/

View File

@ -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;

View File

@ -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 =