ole32: Add a field to the TLS data to determine whether OLE has been initialised for the current thread.

This commit is contained in:
Rob Shearman 2007-01-07 12:16:15 +00:00 committed by Alexandre Julliard
parent 2568c4662a
commit a45a2e37f9
2 changed files with 5 additions and 13 deletions

View File

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

View File

@ -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;
}
@ -242,15 +238,10 @@ 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.