Skip to content

Commit

Permalink
Remixed: Handle already-initialized apartment model.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Dec 4, 2018
1 parent 25f2fd8 commit 71a38ee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Remixed/REM_CAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* params)
MicroProfileSetForceMetaCounters(true);
MicroProfileWebServerStart();

winrt::init_apartment(winrt::apartment_type::single_threaded);
try
{
// Ensure we have initialized the apartment model, pick single_threaded by default for safety
winrt::init_apartment(winrt::apartment_type::single_threaded);
}
catch (const winrt::hresult_error& hr)
{
// If the appartment type was already set to multi_threaded then we can continue as normal
if (hr.code() != RPC_E_CHANGED_MODE)
return ovrError_Initialize;
}

g_MinorVersion = params->RequestedMinorVersion;

Expand Down

0 comments on commit 71a38ee

Please sign in to comment.