Add wxDirect2DModule dependency on wxOleInitModule

This avoids the need for calling CoInitializeEx() and CoUninitialize()
in this module itself, it's enough to ensure that wxOleInitModule does
it before, or after, before this one is initialized, or uninitialized,
respectively.

This replaces the earlier fix of 450019dc21 (Ensure COM is still active
when Direct2D renderer is in use, 2015-12-30).

See #17308.
This commit is contained in:
Vadim Zeitlin
2020-04-19 17:04:36 +02:00
parent 05059b64f1
commit 893f3a6c00

View File

@@ -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: