diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-04-10 10:38:25 +0300 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-04-26 14:14:07 +0200 |
commit | 46e7f334fb39b21f8454f389a7a98070e8884672 (patch) | |
tree | 8aa40c871ba7a4bce78c6ced4026ddc73e554346 /platform | |
parent | cce2ffda1bed9b62c0d6de9b5d30421519535dc7 (diff) |
[Windows] Cleanup COM library initialization/uninitialization.
(cherry picked from commit 83dc545ea2599458fab4f4aaf46ab61d8ca98fbd)
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 1 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 6 | ||||
-rw-r--r-- | platform/windows/tts_windows.cpp | 1 |
3 files changed, 3 insertions, 5 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 30739c9be7..6ce5fd2dd6 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -4388,5 +4388,4 @@ DisplayServerWindows::~DisplayServerWindows() { if (tts) { memdelete(tts); } - CoUninitialize(); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 6e219fb929..66b7d1284e 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -195,7 +195,6 @@ void OS_Windows::initialize() { IPUnix::make_default(); main_loop = nullptr; - CoInitialize(nullptr); HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory)); if (SUCCEEDED(hr)) { hr = dwrite_factory->GetSystemFontCollection(&font_collection, false); @@ -373,8 +372,6 @@ Vector<String> OS_Windows::get_video_adapter_driver_info() const { return Vector<String>(); } - CoInitialize(nullptr); - HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, uuid, (LPVOID *)&wbemLocator); if (hr != S_OK) { return Vector<String>(); @@ -1505,6 +1502,8 @@ Error OS_Windows::move_to_trash(const String &p_path) { OS_Windows::OS_Windows(HINSTANCE _hInstance) { hInstance = _hInstance; + CoInitializeEx(nullptr, COINIT_MULTITHREADED); + #ifdef WASAPI_ENABLED AudioDriverManager::add_driver(&driver_wasapi); #endif @@ -1532,4 +1531,5 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { } OS_Windows::~OS_Windows() { + CoUninitialize(); } diff --git a/platform/windows/tts_windows.cpp b/platform/windows/tts_windows.cpp index 6b4b09b2b9..907096d890 100644 --- a/platform/windows/tts_windows.cpp +++ b/platform/windows/tts_windows.cpp @@ -251,7 +251,6 @@ TTS_Windows *TTS_Windows::get_singleton() { TTS_Windows::TTS_Windows() { singleton = this; - CoInitialize(nullptr); if (SUCCEEDED(CoCreateInstance(CLSID_SpVoice, nullptr, CLSCTX_ALL, IID_ISpVoice, (void **)&synth))) { ULONGLONG event_mask = SPFEI(SPEI_END_INPUT_STREAM) | SPFEI(SPEI_START_INPUT_STREAM) | SPFEI(SPEI_WORD_BOUNDARY); |