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: Fix FreeLibrary not always being called in DisplayServerWindows::dialog_show #89192

Merged
Merged
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
15 changes: 7 additions & 8 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2531,17 +2531,15 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
config.pButtons = tbuttons;
config.pfCallback = win32_task_dialog_callback;

Error result = FAILED;
HMODULE comctl = LoadLibraryW(L"comctl32.dll");
if (comctl) {
typedef HRESULT(WINAPI * TaskDialogIndirectPtr)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);

TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)GetProcAddress(comctl, "TaskDialogIndirect");
if (task_dialog_indirect) {
int button_pressed;
if (FAILED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
return FAILED;
}
int button_pressed;

if (task_dialog_indirect && SUCCEEDED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
if (!p_callback.is_null()) {
Variant button = button_pressed;
const Variant *args[1] = { &button };
Expand All @@ -2553,13 +2551,14 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
}
}

return OK;
result = OK;
}
FreeLibrary(comctl);
} else {
ERR_PRINT("Unable to create native dialog.");
}

ERR_PRINT("Unable to create native dialog.");
return FAILED;
return result;
}

struct Win32InputTextDialogInit {
Expand Down
Loading