Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Initialize COM as apartment-threaded. #79693

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/wasapi/audio_driver_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ void AudioDriverWASAPI::write_sample(WORD format_tag, int bits_per_sample, BYTE
}

void AudioDriverWASAPI::thread_func(void *p_udata) {
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

AudioDriverWASAPI *ad = static_cast<AudioDriverWASAPI *>(p_udata);
uint32_t avail_frames = 0;
Expand Down
7 changes: 6 additions & 1 deletion platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ Error DisplayServerWindows::file_dialog_show(const String &p_title, const String
pfd->SetFileTypes(filters.size(), filters.ptr());
pfd->SetFileTypeIndex(0);

hr = pfd->Show(nullptr);
WindowID window_id = _get_focused_window_or_popup();
if (!windows.has(window_id)) {
window_id = MAIN_WINDOW_ID;
}

hr = pfd->Show(windows[window_id].hWnd);
if (SUCCEEDED(hr)) {
Vector<String> file_names;

Expand Down
2 changes: 1 addition & 1 deletion platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ String OS_Windows::get_system_ca_certificates() {
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
hInstance = _hInstance;

CoInitializeEx(nullptr, COINIT_MULTITHREADED);
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

#ifdef WASAPI_ENABLED
AudioDriverManager::add_driver(&driver_wasapi);
Expand Down