From e54855e1cfbc775f586a08a6298248b52559e2f8 Mon Sep 17 00:00:00 2001 From: dinhngtu <1257909+dinhngtu@users.noreply.github.com> Date: Sun, 8 Dec 2024 05:39:23 +0100 Subject: [PATCH] Don't fail ModernSHBrowseForFolderW when DefaultFolder cannot be set. (#529) --- NanaZip.Shared/ModernWin32FileBrowser.cpp | 28 +++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/NanaZip.Shared/ModernWin32FileBrowser.cpp b/NanaZip.Shared/ModernWin32FileBrowser.cpp index b009d7730..54c84c770 100644 --- a/NanaZip.Shared/ModernWin32FileBrowser.cpp +++ b/NanaZip.Shared/ModernWin32FileBrowser.cpp @@ -51,24 +51,22 @@ EXTERN_C PIDLIST_ABSOLUTE WINAPI ModernSHBrowseForFolderW( nullptr, IID_PPV_ARGS(&DefaultFolder)))) { - if (SUCCEEDED(FileDialog->SetDefaultFolder( - DefaultFolder))) + FileDialog->SetDefaultFolder(DefaultFolder); + + DefaultFolder->Release(); + } + + if (SUCCEEDED(FileDialog->Show( + lpbi->hwndOwner))) + { + IShellItem* Result = nullptr; + if (SUCCEEDED(FileDialog->GetResult( + &Result))) { - if (SUCCEEDED(FileDialog->Show( - lpbi->hwndOwner))) - { - IShellItem* Result = nullptr; - if (SUCCEEDED(FileDialog->GetResult( - &Result))) - { - ::SHGetIDListFromObject(Result, &IDList); + ::SHGetIDListFromObject(Result, &IDList); - Result->Release(); - } - } + Result->Release(); } - - DefaultFolder->Release(); } } }