# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1336200520 0 # Node ID 873304f581beb6e07a94c1c957e856480aa32008 # Parent 043db6b221c2b10f54de8b7d355bafaaaf20abd6 Fix Unicode issues with the directory browser on Windows. Fix a hang with the directory browser on Mac when passing an empty string. diff -r 043db6b221c2 -r 873304f581be mac/dw.m --- a/mac/dw.m Thu May 03 18:44:08 2012 +0000 +++ b/mac/dw.m Sat May 05 06:48:40 2012 +0000 @@ -3208,7 +3208,7 @@ /* Figure out path information... * These functions are only support in Snow Leopard and later... */ - if(defpath && DWOSMinor > 5) + if(defpath && *defpath && DWOSMinor > 5) { struct stat buf; @@ -3273,7 +3273,7 @@ } /* Handle file types */ - if(ext) + if(ext && *ext) { NSArray* fileTypes = [[[NSArray alloc] initWithObjects:[NSString stringWithUTF8String:ext], nil] autorelease]; [openDlg setAllowedFileTypes:fileTypes]; @@ -3314,7 +3314,7 @@ [saveDlg setCanCreateDirectories:YES]; /* Handle file types */ - if(ext) + if(ext && *ext) { NSArray* fileTypes = [[[NSArray alloc] initWithObjects:[NSString stringWithUTF8String:ext], nil] autorelease]; [saveDlg setAllowedFileTypes:fileTypes]; diff -r 043db6b221c2 -r 873304f581be win/dw.c --- a/win/dw.c Thu May 03 18:44:08 2012 +0000 +++ b/win/dw.c Sat May 05 06:48:40 2012 +0000 @@ -11490,7 +11490,7 @@ bi.hwndOwner = NULL; bi.pszDisplayName = 0; bi.pidlRoot = 0; - bi.lpszTitle = title; + bi.lpszTitle = UTF8toWide(title); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; bi.lpfn = NULL; /*BrowseCallbackProc*/ @@ -11499,20 +11499,20 @@ { if (SHGetPathFromIDList(pidl,szDir)) { - strncpy(filenamebuf,szDir,1000); + _tcsncpy(filenamebuf,szDir,1000); } /* In C++: pMalloc->Free(pidl); pMalloc->Release(); */ pMalloc->lpVtbl->Free(pMalloc,pidl); pMalloc->lpVtbl->Release(pMalloc); - return _strdup(filenamebuf); + return _strdup(WideToUTF8(filenamebuf)); } } #else if ( XBrowseForFolder( NULL, - (LPCTSTR)defpath, + (LPCTSTR)dpath, -1, - (LPCTSTR)title, + (LPCTSTR)UTF8toWide(title), (LPTSTR)filenamebuf, 1000, FALSE ) )