Skip to content

Commit

Permalink
Merge pull request mkdasher#58 from 1ted59/1ted59-patch-1
Browse files Browse the repository at this point in the history
Fix cancelling on file dialog selection
  • Loading branch information
Aurumaker72 authored May 14, 2022
2 parents e30300f + ece1599 commit edf2ace
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main/win/wrapper/ReassociatingFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bool ReassociatingFileDialog::ShowFileDialog(char* path, const wchar_t* fTypes,
IShellItem* pShellItem = nullptr;
PWSTR pFilePath = nullptr;
DWORD dwFlags;
bool succeeded = false;

// fighting with "almost-managed-but-not-quite-this-sucks" winapi
// technically IFileOpenDialog/IFileSaveDialog should be used in case but they inherit from same base class and thus allow us to do this unsafe monstrosity
Expand Down Expand Up @@ -43,11 +44,13 @@ bool ReassociatingFileDialog::ShowFileDialog(char* path, const wchar_t* fTypes,

wcstombs(path, pFilePath, MAX_PATH);
wcsncpy(lastPath, pFilePath, MAX_PATH);

succeeded = true;

cleanUp:
if (pFilePath) CoTaskMemFree(pFilePath);
if (pShellItem) pShellItem->Release();
if (pFileDialog) pFileDialog->Release();

return strlen(path) > 0;
return succeeded && strlen(path) > 0;
}

0 comments on commit edf2ace

Please sign in to comment.