summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorashok <ashok>2015-10-06 06:14:34 (GMT)
committerashok <ashok>2015-10-06 06:14:34 (GMT)
commit1a403e858b44dbf3d3a12d896877397894fe3e36 (patch)
tree5c38184a59339360f983ca1dc562e900e67a2b0c /win
parent86963de77f6884f72a81978958e2df8f5e0c4b95 (diff)
downloadtk-1a403e858b44dbf3d3a12d896877397894fe3e36.zip
tk-1a403e858b44dbf3d3a12d896877397894fe3e36.tar.gz
tk-1a403e858b44dbf3d3a12d896877397894fe3e36.tar.bz2
Fix for [46c83f60] (relative paths ignored in tk_getOpenFile/tk_getSaveFile on Vista+). Added tests for -initialdir option.
Diffstat (limited to 'win')
-rw-r--r--win/tkWinDialog.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index dc385e3..0188296 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -1388,18 +1388,27 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
}
if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') {
- Tcl_DString dirString;
- Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString),
- Tcl_DStringLength(&optsPtr->utfDirString), &dirString);
- hr = ShellProcs.SHCreateItemFromParsingName(
- (TCHAR *) Tcl_DStringValue(&dirString), NULL,
- &IIDIShellItem, (void **) &dirIf);
- /* XXX - Note on failure we do not raise error, simply ignore ini dir */
- if (SUCCEEDED(hr)) {
- /* Note we use SetFolder, not SetDefaultFolder - see MSDN docs */
- fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */
+ Tcl_Obj *normPath, *iniDirPath;
+ iniDirPath = Tcl_NewStringObj(Tcl_DStringValue(&optsPtr->utfDirString), -1);
+ Tcl_IncrRefCount(iniDirPath);
+ normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath);
+ /* XXX - Note on failures do not raise error, simply ignore ini dir */
+ if (normPath) {
+ const WCHAR *nativePath;
+ Tcl_IncrRefCount(normPath);
+ nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
+ if (nativePath) {
+ hr = ShellProcs.SHCreateItemFromParsingName(
+ nativePath, NULL,
+ &IIDIShellItem, (void **) &dirIf);
+ if (SUCCEEDED(hr)) {
+ /* Note we use SetFolder, not SetDefaultFolder - see MSDN */
+ fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */
+ }
+ }
+ Tcl_DecrRefCount(normPath); /* ALSO INVALIDATES nativePath !! */
}
- Tcl_DStringFree(&dirString);
+ Tcl_DecrRefCount(iniDirPath);
}
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);