ole32: Add a helper for grabbing the current apartment or MTA.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
21fe96a820
commit
5e752db1ba
|
@ -734,6 +734,19 @@ static APARTMENT *apartment_find_mta(void)
|
||||||
return apt;
|
return apt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the current apartment if it exists, or, failing that, the MTA. Caller
|
||||||
|
* must free the returned apartment in either case. */
|
||||||
|
static APARTMENT *apartment_get_current_or_mta(void)
|
||||||
|
{
|
||||||
|
APARTMENT *apt = COM_CurrentApt();
|
||||||
|
if (apt)
|
||||||
|
{
|
||||||
|
apartment_addref(apt);
|
||||||
|
return apt;
|
||||||
|
}
|
||||||
|
return apartment_find_mta();
|
||||||
|
}
|
||||||
|
|
||||||
static void COM_RevokeRegisteredClassObject(RegisteredClass *curClass)
|
static void COM_RevokeRegisteredClassObject(RegisteredClass *curClass)
|
||||||
{
|
{
|
||||||
list_remove(&curClass->entry);
|
list_remove(&curClass->entry);
|
||||||
|
@ -2997,15 +3010,10 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
|
||||||
|
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
|
||||||
if ((apt = COM_CurrentApt()))
|
if (!(apt = apartment_get_current_or_mta()))
|
||||||
apartment_addref(apt);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (!(apt = apartment_find_mta()))
|
ERR("apartment not initialised\n");
|
||||||
{
|
return CO_E_NOTINITIALIZED;
|
||||||
ERR("apartment not initialised\n");
|
|
||||||
return CO_E_NOTINITIALIZED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pServerInfo) {
|
if (pServerInfo) {
|
||||||
|
@ -3298,15 +3306,12 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
clsid = *rclsid;
|
clsid = *rclsid;
|
||||||
|
|
||||||
if (!(apt = COM_CurrentApt()))
|
if (!(apt = apartment_get_current_or_mta()))
|
||||||
{
|
{
|
||||||
if (!(apt = apartment_find_mta()))
|
ERR("apartment not initialised\n");
|
||||||
{
|
return CO_E_NOTINITIALIZED;
|
||||||
ERR("apartment not initialised\n");
|
|
||||||
return CO_E_NOTINITIALIZED;
|
|
||||||
}
|
|
||||||
apartment_release(apt);
|
|
||||||
}
|
}
|
||||||
|
apartment_release(apt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Standard Global Interface Table (GIT) object is a process-wide singleton.
|
* The Standard Global Interface Table (GIT) object is a process-wide singleton.
|
||||||
|
@ -4998,22 +5003,19 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv)
|
||||||
HRESULT WINAPI CoGetContextToken( ULONG_PTR *token )
|
HRESULT WINAPI CoGetContextToken( ULONG_PTR *token )
|
||||||
{
|
{
|
||||||
struct oletls *info = COM_CurrentInfo();
|
struct oletls *info = COM_CurrentInfo();
|
||||||
|
APARTMENT *apt;
|
||||||
|
|
||||||
TRACE("(%p)\n", token);
|
TRACE("(%p)\n", token);
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
if (!info->apt)
|
if (!(apt = apartment_get_current_or_mta()))
|
||||||
{
|
{
|
||||||
APARTMENT *apt;
|
ERR("apartment not initialised\n");
|
||||||
if (!(apt = apartment_find_mta()))
|
return CO_E_NOTINITIALIZED;
|
||||||
{
|
|
||||||
ERR("apartment not initialised\n");
|
|
||||||
return CO_E_NOTINITIALIZED;
|
|
||||||
}
|
|
||||||
apartment_release(apt);
|
|
||||||
}
|
}
|
||||||
|
apartment_release(apt);
|
||||||
|
|
||||||
if (!token)
|
if (!token)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
Loading…
Reference in New Issue