mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-08 17:41:41 +01:00
JBR-1258 CommonItemDialog ignores directory to open
Fix parsing of directory path / file path
(cherry picked from commit b09a8aace1)
This commit is contained in:
committed by
jbrbot
parent
4c5adae498
commit
23fd66b0d9
@@ -564,7 +564,7 @@ HRESULT CDialogEventHandler_CreateInstance(FileDialogData *data, REFIID riid, vo
|
||||
OLE_RETURN_HR
|
||||
}
|
||||
|
||||
HRESULT CreateShellItem(LPTSTR path, IShellItem *shellItem) {
|
||||
HRESULT CreateShellItem(LPTSTR path, IShellItemPtr& shellItem) {
|
||||
size_t pathLength = _tcslen(path);
|
||||
for (size_t index = 0; index < pathLength; index++) {
|
||||
if (path[index] == _T('/'))
|
||||
@@ -608,7 +608,7 @@ AwtFileDialog::Show(void *p)
|
||||
IFileDialogEventsPtr pfde;
|
||||
IShellItemPtr psiResult;
|
||||
FileDialogData data;
|
||||
DWORD dwCookie;
|
||||
DWORD dwCookie = OLE_BAD_COOKIE;
|
||||
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
@@ -730,9 +730,11 @@ AwtFileDialog::Show(void *p)
|
||||
OLE_HRT(pfd->SetFileTypeIndex(1));
|
||||
|
||||
IShellItemPtr directoryItem;
|
||||
if (SUCCEEDED(CreateShellItem(directoryBuffer, directoryItem))) {
|
||||
pfd->SetFolder(directoryItem);
|
||||
}
|
||||
OLE_NEXT_TRY
|
||||
OLE_HRT(CreateShellItem(directoryBuffer, directoryItem));
|
||||
OLE_HRT(pfd->SetFolder(directoryItem));
|
||||
OLE_CATCH
|
||||
|
||||
CoTaskStringHolder shortName = GetShortName(fileBuffer);
|
||||
if (shortName) {
|
||||
OLE_HRT(pfd->SetFileName(shortName));
|
||||
@@ -831,7 +833,7 @@ AwtFileDialog::Show(void *p)
|
||||
} catch (...) {
|
||||
|
||||
if (useCommonItemDialog) {
|
||||
if (pfd) {
|
||||
if (pfd && dwCookie != OLE_BAD_COOKIE) {
|
||||
pfd->Unadvise(dwCookie);
|
||||
}
|
||||
}
|
||||
@@ -851,7 +853,7 @@ AwtFileDialog::Show(void *p)
|
||||
}
|
||||
|
||||
if (useCommonItemDialog) {
|
||||
if (pfd) {
|
||||
if (pfd && dwCookie != OLE_BAD_COOKIE) {
|
||||
pfd->Unadvise(dwCookie);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user