From c4f493a7c8b1f934def6b3008539b9a52ff6b406 Mon Sep 17 00:00:00 2001 From: Rajendra Singh Date: Sun, 3 Mar 2019 11:53:06 +0530 Subject: [PATCH] Fixed file open hang issue in old style mode Fix #5368, close #5370 --- .../WinControls/OpenSaveFileDialog/FileDialog.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 34a7392b..99df367d 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -474,15 +474,19 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM, LPARAM lParam) { // change to backslash, and insert trailing '\' to indicate directory hFileDlg = ::GetParent(hWnd); - std::wstring _fnStr(fileName); - std::replace(_fnStr.begin(), _fnStr.end(), '/', '\\'); + std::wstring filePath(fileName); + std::replace(filePath.begin(), filePath.end(), '/', '\\'); - if (_fnStr.back() != '\\') - _fnStr.insert(_fnStr.end(), '\\'); + if (filePath.back() != '\\') + filePath.insert(filePath.end(), '\\'); + + // There are two or more double backslash, then change it to single + while (filePath.find(L"\\\\") != std::wstring::npos) + filePath.replace(filePath.find(TEXT("\\\\")), 2, TEXT("\\")); // change the dialog directory selection ::SendMessage(hFileDlg, CDM_SETCONTROLTEXT, edt1, - reinterpret_cast(_fnStr.c_str())); + reinterpret_cast(filePath.c_str())); ::PostMessage(hFileDlg, WM_COMMAND, IDOK, 0); ::SetWindowLongPtr(hWnd, 0 /*DWL_MSGRESULT*/, 1); }