combase: Move thread data cleanup.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
904f5fd0f6
commit
2452c8c6cd
|
@ -403,6 +403,36 @@ HRESULT WINAPI InternalTlsAllocData(struct tlsdata **data)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static void com_cleanup_tlsdata(void)
|
||||
{
|
||||
struct tlsdata *tlsdata = NtCurrentTeb()->ReservedForOle;
|
||||
struct init_spy *cursor, *cursor2;
|
||||
|
||||
if (!tlsdata)
|
||||
return;
|
||||
|
||||
if (tlsdata->apt)
|
||||
apartment_release(tlsdata->apt);
|
||||
if (tlsdata->errorinfo)
|
||||
IErrorInfo_Release(tlsdata->errorinfo);
|
||||
if (tlsdata->state)
|
||||
IUnknown_Release(tlsdata->state);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &tlsdata->spies, struct init_spy, entry)
|
||||
{
|
||||
list_remove(&cursor->entry);
|
||||
if (cursor->spy)
|
||||
IInitializeSpy_Release(cursor->spy);
|
||||
heap_free(cursor);
|
||||
}
|
||||
|
||||
if (tlsdata->context_token)
|
||||
IObjContext_Release(tlsdata->context_token);
|
||||
|
||||
heap_free(tlsdata);
|
||||
NtCurrentTeb()->ReservedForOle = NULL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* FreePropVariantArray (combase.@)
|
||||
*/
|
||||
|
@ -2955,6 +2985,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
|
|||
apartment_global_cleanup();
|
||||
DeleteCriticalSection(®istered_classes_cs);
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
com_cleanup_tlsdata();
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -489,31 +489,6 @@ HRESULT WINAPI ManualResetEvent_CreateInstance(IClassFactory *iface, IUnknown *o
|
|||
return hr;
|
||||
}
|
||||
|
||||
static void COM_TlsDestroy(void)
|
||||
{
|
||||
struct oletls *info = NtCurrentTeb()->ReservedForOle;
|
||||
if (info)
|
||||
{
|
||||
struct init_spy *cursor, *cursor2;
|
||||
|
||||
if (info->apt) apartment_release(info->apt);
|
||||
if (info->errorinfo) IErrorInfo_Release(info->errorinfo);
|
||||
if (info->state) IUnknown_Release(info->state);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &info->spies, struct init_spy, entry)
|
||||
{
|
||||
list_remove(&cursor->entry);
|
||||
if (cursor->spy) IInitializeSpy_Release(cursor->spy);
|
||||
heap_free(cursor);
|
||||
}
|
||||
|
||||
if (info->context_token) IObjContext_Release(info->context_token);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, info);
|
||||
NtCurrentTeb()->ReservedForOle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* CoBuildVersion [OLE32.@]
|
||||
*
|
||||
|
@ -1324,10 +1299,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID reserved)
|
|||
release_std_git();
|
||||
RPC_UnregisterAllChannelHooks();
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
COM_TlsDestroy();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue