msctf: Moved thread manager's sink list destructor 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:41:13 +02:00 committed by Alexandre Julliard
parent 0374ee290d
commit a27da35b05
3 changed files with 16 additions and 43 deletions

View File

@ -323,6 +323,15 @@ HRESULT unadvise_sink(DWORD cookie)
return S_OK; return S_OK;
} }
void free_sinks(struct list *sink_list)
{
while(!list_empty(sink_list))
{
Sink* sink = LIST_ENTRY(sink_list->next, Sink, entry);
free_sink(sink);
}
}
/***************************************************************************** /*****************************************************************************
* Active Text Service Management * Active Text Service Management
*****************************************************************************/ *****************************************************************************/

View File

@ -77,6 +77,7 @@ typedef struct {
HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie) DECLSPEC_HIDDEN; 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; HRESULT unadvise_sink(DWORD cookie) DECLSPEC_HIDDEN;
void free_sinks(struct list *sink_list) DECLSPEC_HIDDEN;
extern const WCHAR szwSystemTIPKey[] DECLSPEC_HIDDEN; extern const WCHAR szwSystemTIPKey[] DECLSPEC_HIDDEN;
extern const WCHAR szwSystemCTFKey[] DECLSPEC_HIDDEN; extern const WCHAR szwSystemCTFKey[] DECLSPEC_HIDDEN;

View File

@ -157,12 +157,6 @@ static inline EnumTfDocumentMgr *impl_from_IEnumTfDocumentMgrs(IEnumTfDocumentMg
return CONTAINING_RECORD(iface, EnumTfDocumentMgr, IEnumTfDocumentMgrs_iface); return CONTAINING_RECORD(iface, EnumTfDocumentMgr, IEnumTfDocumentMgrs_iface);
} }
static void free_sink(Sink *sink)
{
IUnknown_Release(sink->interfaces.pIUnknown);
HeapFree(GetProcessHeap(),0,sink);
}
static void ThreadMgr_Destructor(ThreadMgr *This) static void ThreadMgr_Destructor(ThreadMgr *This)
{ {
struct list *cursor, *cursor2; struct list *cursor, *cursor2;
@ -176,43 +170,12 @@ static void ThreadMgr_Destructor(ThreadMgr *This)
if (This->focus) if (This->focus)
ITfDocumentMgr_Release(This->focus); ITfDocumentMgr_Release(This->focus);
/* free sinks */ free_sinks(&This->ActiveLanguageProfileNotifySink);
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ActiveLanguageProfileNotifySink) free_sinks(&This->DisplayAttributeNotifySink);
{ free_sinks(&This->KeyTraceEventSink);
Sink* sink = LIST_ENTRY(cursor,Sink,entry); free_sinks(&This->PreservedKeyNotifySink);
list_remove(cursor); free_sinks(&This->ThreadFocusSink);
free_sink(sink); free_sinks(&This->ThreadMgrEventSink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->DisplayAttributeNotifySink)
{
Sink* sink = LIST_ENTRY(cursor,Sink,entry);
list_remove(cursor);
free_sink(sink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->KeyTraceEventSink)
{
Sink* sink = LIST_ENTRY(cursor,Sink,entry);
list_remove(cursor);
free_sink(sink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->PreservedKeyNotifySink)
{
Sink* sink = LIST_ENTRY(cursor,Sink,entry);
list_remove(cursor);
free_sink(sink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadFocusSink)
{
Sink* sink = LIST_ENTRY(cursor,Sink,entry);
list_remove(cursor);
free_sink(sink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadMgrEventSink)
{
Sink* sink = LIST_ENTRY(cursor,Sink,entry);
list_remove(cursor);
free_sink(sink);
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CurrentPreservedKeys) LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CurrentPreservedKeys)
{ {