From c851ecca2bc36a88aa6c099f2ad142406a8e6391 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lauri=20Kentt=C3=A4?= Date: Wed, 6 Jul 2016 13:27:44 +0300 Subject: [PATCH] comdlg32: Avoid repeated GlobalLock etc in filedlg. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Lauri Kenttä Signed-off-by: Alexandre Julliard --- dlls/comdlg32/filedlg.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index a04e6462a00..0fbb6218654 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -225,6 +225,7 @@ LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl); static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName); static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl); static UINT GetNumSelected( IDataObject *doSelected ); +static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium); /* Shell memory allocation */ static void *MemAlloc(UINT size); @@ -3649,12 +3650,18 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) LPITEMIDLIST pidl; LPWSTR lpstrAllFiles, lpstrTmp; UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength; + STGMEDIUM medium; + LPIDA cida; + FORMATETC formatetc = get_def_format(); TRACE("\n"); fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr); - /* Count how many files we have */ - nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject ); + if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium))) + return; + + cida = GlobalLock(medium.u.hGlobal); + nFileSelected = cida->cidl; /* Allocate a buffer */ nAllFilesMaxLength = MAX_PATH + 3; @@ -3665,7 +3672,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) /* Loop through the selection, handle only files (not folders) */ for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++) { - pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 ); + pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]); if (pidl) { if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) @@ -3686,7 +3693,6 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) lpstrAllFiles[nAllFilesLength++] = '"'; lpstrAllFiles[nAllFilesLength++] = ' '; } - COMDLG32_SHFree(pidl); } } @@ -3707,6 +3713,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) ret: HeapFree(GetProcessHeap(), 0, lpstrAllFiles); + COMCTL32_ReleaseStgMedium(medium); } -- 2.11.4.GIT