Commit a45a2e37 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Add a field to the TLS data to determine whether OLE has been initialised…

ole32: Add a field to the TLS data to determine whether OLE has been initialised for the current thread.
parent 2568c466
......@@ -168,6 +168,7 @@ struct oletls
IErrorInfo *errorinfo; /* see errorinfo.c */
IUnknown *state; /* see CoSetState */
DWORD inits; /* number of times CoInitializeEx called */
DWORD ole_inits; /* number of times OleInitialize called */
GUID causality_id; /* unique identifier for each COM call */
LONG pending_call_count_client; /* number of client calls pending */
LONG pending_call_count_server; /* number of server calls pending */
......
......@@ -107,7 +107,7 @@ static OleMenuHookItem *hook_list;
* This is the lock count on the OLE library. It is controlled by the
* OLEInitialize/OLEUninitialize methods.
*/
static ULONG OLE_moduleLockCount = 0;
static LONG OLE_moduleLockCount = 0;
/*
* Name of our registered window class.
......@@ -203,7 +203,8 @@ HRESULT WINAPI OleInitialize(LPVOID reserved)
* Object linking and Embedding
* In-place activation
*/
if (OLE_moduleLockCount==0)
if (!COM_CurrentInfo()->ole_inits++ &&
InterlockedIncrement(&OLE_moduleLockCount) == 1)
{
/*
* Initialize the libraries.
......@@ -226,11 +227,6 @@ HRESULT WINAPI OleInitialize(LPVOID reserved)
OLEMenu_Initialize();
}
/*
* Then, we increase the lock count on the OLE module.
*/
OLE_moduleLockCount++;
return hr;
}
......@@ -243,14 +239,9 @@ void WINAPI OleUninitialize(void)
TRACE("()\n");
/*
* Decrease the lock count on the OLE module.
*/
OLE_moduleLockCount--;
/*
* If we hit the bottom of the lock stack, free the libraries.
*/
if (OLE_moduleLockCount==0)
if (!--COM_CurrentInfo()->ole_inits && !InterlockedDecrement(&OLE_moduleLockCount))
{
/*
* Actually free the libraries.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment