Fix crash issue due to Unix style path input in Open file dialog.
This issue occurs when "Use New Style Dialog" setting is not used . Ctrl+O, then type D:/*.log and hit Enter. Fix #4946, close #4986
This commit is contained in:
parent
08b0156472
commit
b9b3faf307
@ -352,15 +352,18 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||||||
if (globbing)
|
if (globbing)
|
||||||
{
|
{
|
||||||
const TCHAR * substring = wcsrchr(fileName.c_str(), TCHAR('\\'));
|
const TCHAR * substring = wcsrchr(fileName.c_str(), TCHAR('\\'));
|
||||||
size_t pos = substring - fileName.c_str();
|
if (substring)
|
||||||
|
{
|
||||||
|
size_t pos = substring - fileName.c_str();
|
||||||
|
|
||||||
patterns.push_back(substring + 1);
|
patterns.push_back(substring + 1);
|
||||||
generic_string dir(fileName.c_str(), pos + 1); // use char * to evoke:
|
generic_string dir(fileName.c_str(), pos + 1); // use char * to evoke:
|
||||||
// string (const char* s, size_t n);
|
// string (const char* s, size_t n);
|
||||||
// and avoid to call (if pass string) :
|
// and avoid to call (if pass string) :
|
||||||
// string (const string& str, size_t pos, size_t len = npos);
|
// string (const string& str, size_t pos, size_t len = npos);
|
||||||
|
|
||||||
getMatchedFileNames(dir.c_str(), patterns, fileNames, isRecursive, false);
|
getMatchedFileNames(dir.c_str(), patterns, fileNames, isRecursive, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
|
|||||||
_ofn.lpfnHook = NULL;
|
_ofn.lpfnHook = NULL;
|
||||||
_ofn.lpstrDefExt = NULL; // No default extension
|
_ofn.lpstrDefExt = NULL; // No default extension
|
||||||
_ofn.lCustData = 0;
|
_ofn.lCustData = 0;
|
||||||
_ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_LONGNAMES | DS_CENTER | OFN_HIDEREADONLY;
|
_ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_LONGNAMES | OFN_HIDEREADONLY;
|
||||||
_ofn.pvReserved = NULL;
|
_ofn.pvReserved = NULL;
|
||||||
_ofn.dwReserved = 0;
|
_ofn.dwReserved = 0;
|
||||||
_ofn.FlagsEx = 0;
|
_ofn.FlagsEx = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user