Skip to content

Commit

Permalink
Switch back to apartment threaded COM initialization, which was the p…
Browse files Browse the repository at this point in the history
…revious default.

We do succeed now if the application previously initialized COM in multi-threaded mode.
  • Loading branch information
slouken committed Dec 27, 2013
1 parent 6f6c76a commit 6915319
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/windows/SDL_windows.c
Expand Up @@ -45,7 +45,15 @@ WIN_SetError(const char *prefix)
HRESULT
WIN_CoInitialize(void)
{
const HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
/* SDL handles any threading model, so initialize with the default, which
is compatible with OLE and if that doesn't work, try multi-threaded mode.
If you need multi-threaded mode, call CoInitializeEx() before SDL_Init()
*/
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (hr == RPC_E_CHANGED_MODE) {
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
}

/* S_FALSE means success, but someone else already initialized. */
/* You still need to call CoUninitialize in this case! */
Expand Down

0 comments on commit 6915319

Please sign in to comment.