Merge pull request #89192 from 398utubzyt/windows/free-lib-in-dialog-show

Windows: Fix `FreeLibrary` not always being called in `DisplayServerWindows::dialog_show`
This commit is contained in:
Rémi Verschelde 2024-03-05 23:44:42 +01:00
commit 8b0eecdfae
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -2531,17 +2531,15 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
config.pButtons = tbuttons; config.pButtons = tbuttons;
config.pfCallback = win32_task_dialog_callback; config.pfCallback = win32_task_dialog_callback;
Error result = FAILED;
HMODULE comctl = LoadLibraryW(L"comctl32.dll"); HMODULE comctl = LoadLibraryW(L"comctl32.dll");
if (comctl) { if (comctl) {
typedef HRESULT(WINAPI * TaskDialogIndirectPtr)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked); typedef HRESULT(WINAPI * TaskDialogIndirectPtr)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)GetProcAddress(comctl, "TaskDialogIndirect"); TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)GetProcAddress(comctl, "TaskDialogIndirect");
if (task_dialog_indirect) { int button_pressed;
int button_pressed;
if (FAILED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
return FAILED;
}
if (task_dialog_indirect && SUCCEEDED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
if (!p_callback.is_null()) { if (!p_callback.is_null()) {
Variant button = button_pressed; Variant button = button_pressed;
const Variant *args[1] = { &button }; const Variant *args[1] = { &button };
@ -2553,13 +2551,14 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
} }
} }
return OK; result = OK;
} }
FreeLibrary(comctl); FreeLibrary(comctl);
} else {
ERR_PRINT("Unable to create native dialog.");
} }
ERR_PRINT("Unable to create native dialog."); return result;
return FAILED;
} }
struct Win32InputTextDialogInit { struct Win32InputTextDialogInit {