summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorashok <ashok@noemail.net>2015-10-06 06:14:34 (GMT)
committerashok <ashok@noemail.net>2015-10-06 06:14:34 (GMT)
commitcba4fb614eb29a9a2f6e972f40c3946e6870aa46 (patch)
tree5c38184a59339360f983ca1dc562e900e67a2b0c /win
parent16f52411b466613a30669d4afcd4d7f53932c47a (diff)
downloadtk-cba4fb614eb29a9a2f6e972f40c3946e6870aa46.zip
tk-cba4fb614eb29a9a2f6e972f40c3946e6870aa46.tar.gz
tk-cba4fb614eb29a9a2f6e972f40c3946e6870aa46.tar.bz2
Fix for http://core.tcl.tk/tk/tktview?name=46c83f603f (relative paths ignored
in tk_getOpenFile/tk_getSaveFile on Vista+). Added tests for -initialdir option. FossilOrigin-Name: 45da3436824fed73bc41366b7d5dfe374165380f
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);