From 841bc52027190fd5538403f10e54a2be3ef323e9 Mon Sep 17 00:00:00 2001 From: Tomas Dittmann Date: Tue, 22 Aug 2017 23:07:36 +0200 Subject: [PATCH] Use desktop-hwnd as directorydialog-owner, fixes #6198 Restore the mainwindow after the dialog. Correctly cleanup COM memory. --- src/openrct2-ui/UiContext.Win32.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openrct2-ui/UiContext.Win32.cpp b/src/openrct2-ui/UiContext.Win32.cpp index 8db8cc49c3..4eb09a7900 100644 --- a/src/openrct2-ui/UiContext.Win32.cpp +++ b/src/openrct2-ui/UiContext.Win32.cpp @@ -164,7 +164,6 @@ namespace OpenRCT2 { namespace Ui { std::wstring titleW = String::ToUtf16(title); BROWSEINFOW bi = { 0 }; - bi.hwndOwner = GetHWND(window); bi.lpszTitle = titleW.c_str(); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON; @@ -173,12 +172,18 @@ namespace OpenRCT2 { namespace Ui { result = String::ToUtf8(SHGetPathFromIDListLongPath(pidl)); } + CoTaskMemFree(pidl); } else { log_error("Error opening directory browse window"); } CoUninitialize(); + + // SHBrowseForFolderW might minimize the main window, + // so make sure that it's visible again. + ShowWindow(GetHWND(window), SW_RESTORE); + return result; }