diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 7ad74fc4e2..9231d36d6c 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -5247,14 +5247,14 @@ class wxDirect2DModule : public wxModule public: wxDirect2DModule() { + // Using Direct2D requires OLE and, importantly, we must ensure our + // OnExit() runs before it is uninitialized. + AddDependency("wxOleInitModule"); } virtual bool OnInit() wxOVERRIDE { - HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - // RPC_E_CHANGED_MODE is not considered as an error - // - see remarks for wxOleInitialize(). - return SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE; + return true; } virtual void OnExit() wxOVERRIDE @@ -5289,8 +5289,6 @@ public: gs_ID2D1Factory->Release(); gs_ID2D1Factory = NULL; } - - ::CoUninitialize(); } private: