combase: Update thread flags when entering/leaving apartments.

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:
Nikolay Sivov 2020-11-19 13:40:32 +00:00 committed by Alexandre Julliard
parent ffce592cc3
commit 7cae17c134
3 changed files with 12 additions and 4 deletions

View File

@ -556,6 +556,8 @@ static struct apartment *apartment_get_or_create(DWORD model)
if (!apt)
{
com_get_tlsdata(&data);
if (model & COINIT_APARTMENTTHREADED)
{
EnterCriticalSection(&apt_cs);
@ -568,6 +570,10 @@ static struct apartment *apartment_get_or_create(DWORD model)
TRACE("Created main-threaded apartment with OXID %s\n", wine_dbgstr_longlong(apt->oxid));
}
data->flags |= OLETLS_APARTMENTTHREADED;
if (model & COINIT_DISABLE_OLE1DDE)
data->flags |= OLETLS_DISABLE_OLE1DDE;
LeaveCriticalSection(&apt_cs);
if (apt->main)
@ -588,11 +594,12 @@ static struct apartment *apartment_get_or_create(DWORD model)
else
mta = apartment_construct(model);
data->flags |= OLETLS_MULTITHREADED | OLETLS_DISABLE_OLE1DDE;
apt = mta;
LeaveCriticalSection(&apt_cs);
}
com_get_tlsdata(&data);
data->apt = apt;
}
@ -1146,6 +1153,7 @@ void leave_apartment(struct tlsdata *data)
WARN( "Uninitializing apartment while Ole is still initialized\n" );
apartment_release(data->apt);
data->apt = NULL;
data->flags &= ~(OLETLS_DISABLE_OLE1DDE | OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED);
}
}

View File

@ -66,6 +66,9 @@ HRESULT open_appidkey_from_clsid(REFCLSID clsid, REGSAM access, HKEY *subkey) DE
enum tlsdata_flags
{
OLETLS_UUIDINITIALIZED = 0x2,
OLETLS_DISABLE_OLE1DDE = 0x40,
OLETLS_APARTMENTTHREADED = 0x80,
OLETLS_MULTITHREADED = 0x100,
};
/* this is what is stored in TEB->ReservedForOle */

View File

@ -4296,7 +4296,6 @@ static void test_oletlsdata(void)
hr = CoInitialize(NULL);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
flags = get_oletlsflags();
todo_wine
ok(flags & OLETLS_APARTMENTTHREADED && !(flags & OLETLS_DISABLE_OLE1DDE), "Unexpected flags %#x.\n", flags);
CoUninitialize();
flags = get_oletlsflags();
@ -4305,7 +4304,6 @@ todo_wine
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
flags = get_oletlsflags();
todo_wine
ok(flags & OLETLS_APARTMENTTHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags);
CoUninitialize();
flags = get_oletlsflags();
@ -4315,7 +4313,6 @@ todo_wine
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
flags = get_oletlsflags();
todo_wine
ok(flags & OLETLS_MULTITHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags);
/* Implicit case. */