Module: wine Branch: master Commit: c851ecca2bc36a88aa6c099f2ad142406a8e6391 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c851ecca2bc36a88aa6c099f2a...
Author: Lauri Kenttä lauri.kentta@gmail.com Date: Wed Jul 6 13:27:44 2016 +0300
comdlg32: Avoid repeated GlobalLock etc in filedlg.
Signed-off-by: Lauri Kenttä lauri.kentta@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 a04e646..0fbb621 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); }