Module: wine Branch: master Commit: a45a2e37f992a3757b8c3a7f934188b51917fa6e URL: http://source.winehq.org/git/wine.git/?a=commit;h=a45a2e37f992a3757b8c3a7f93...
Author: Rob Shearman rob@codeweavers.com Date: Sun Jan 7 12:16:15 2007 +0000
ole32: Add a field to the TLS data to determine whether OLE has been initialised for the current thread.
---
dlls/ole32/compobj_private.h | 1 + dlls/ole32/ole2.c | 17 ++++------------- 2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 6abfdfd..cfee6e3 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -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 */ diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index 5da68fc..fa02c42 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -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 rese * 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 rese 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.