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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user