From baa3b4ef3bf46ca2dfeda5c8ef36eb5864256164 Mon Sep 17 00:00:00 2001 From: "jshin%mailaps.org" Date: Wed, 19 Apr 2006 00:41:22 +0000 Subject: [PATCH] bug 234946 : Windows File Picker Issues on Win2k or later (full Unicode support) : r=emaijala, sr=neil git-svn-id: svn://10.0.0.236/trunk@194645 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/windows/nsFilePicker.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mozilla/widget/src/windows/nsFilePicker.cpp b/mozilla/widget/src/windows/nsFilePicker.cpp index 6b4ef3f5024..8ee27d96e65 100644 --- a/mozilla/widget/src/windows/nsFilePicker.cpp +++ b/mozilla/widget/src/windows/nsFilePicker.cpp @@ -51,7 +51,6 @@ #include "nsIURL.h" #include "nsIFileURL.h" #include "nsIStringBundle.h" -#include "nsNativeCharsetUtils.h" #include "nsEnumeratorUtils.h" #include "nsCRT.h" #include @@ -111,12 +110,11 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpDa { if (uMsg == BFFM_INITIALIZED) { - char * filePath = (char *) lpData; + PRUnichar * filePath = (PRUnichar *) lpData; if (filePath) - { - ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE /* true because lpData is a path string */, lpData); - nsCRT::free(filePath); - } + ::SendMessageW(hwnd, BFFM_SETSELECTIONW, + TRUE /* true because lpData is a path string */, + lpData); } return 0; } @@ -164,11 +162,11 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) browserInfo.pszDisplayName = (LPWSTR)dirBuffer; browserInfo.lpszTitle = mTitle.get(); browserInfo.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS; - if (initialDir.Length()) // convert folder path to native, the strdup copy will be released in BrowseCallbackProc + if (initialDir.Length()) { - nsCAutoString nativeFolderPath; - NS_CopyUnicodeToNative(initialDir, nativeFolderPath); - browserInfo.lParam = (LPARAM) nsCRT::strdup(nativeFolderPath.get()); + // the dialog is modal so that |initialDir.get()| will be valid in + // BrowserCallbackProc. Thus, we don't need to clone it. + browserInfo.lParam = (LPARAM) initialDir.get(); browserInfo.lpfn = &BrowseCallbackProc; } else @@ -178,7 +176,6 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) } browserInfo.iImage = nsnull; - // XXX UNICODE support is needed here --> DONE LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo); if (list != NULL) { result = ::SHGetPathFromIDListW(list, (LPWSTR)fileBuffer);