diff options
author | dkf <dkf@noemail.net> | 2012-02-10 15:51:52 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2012-02-10 15:51:52 (GMT) |
commit | 010f9eeaf241dc2a57acde1596f372e6cff449bb (patch) | |
tree | 1ec58abec3ff63bfe641b72ede5295e7d902a279 /win | |
parent | a69d2cc51d6f0f7df371c26072d91b7f8b9c3b99 (diff) | |
download | tk-010f9eeaf241dc2a57acde1596f372e6cff449bb.zip tk-010f9eeaf241dc2a57acde1596f372e6cff449bb.tar.gz tk-010f9eeaf241dc2a57acde1596f372e6cff449bb.tar.bz2 |
* win/tkWinDialog.c (GetFileNameW): Ensure that we do not convert a
result list to a string inadvertently, as this causes problems with
Tkinter's handling of multiple filename results. Issue was reported
via StackOverflow: http://stackoverflow.com/q/9227859/301832
FossilOrigin-Name: c309fddc73beb7b643fcba00ed60f351410e5b80
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDialog.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 64fca8b..55152e9 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -834,6 +834,11 @@ GetFileNameW( if ((winCode != 0) || ((cdlgerr == FNERR_BUFFERTOOSMALL) && (ofn.Flags & OFN_ALLOWMULTISELECT))) { + int gotFilename = 0; /* Flag for tracking whether we have any + * filename at all. For details, see + * http://stackoverflow.com/q/9227859/301832 + */ + if (ofn.Flags & OFN_ALLOWMULTISELECT) { /* * The result in dynFileBuffer contains many items, separated by @@ -870,6 +875,7 @@ GetFileNameW( Tcl_AppendToObj(fullnameObj, "/", -1); Tcl_AppendToObj(fullnameObj, Tcl_DStringValue(&filenameBuf), Tcl_DStringLength(&filenameBuf)); + gotFilename = 1; Tcl_DStringFree(&filenameBuf); Tcl_ListObjAppendElement(NULL, returnList, fullnameObj); } @@ -883,18 +889,19 @@ GetFileNameW( Tcl_ListObjAppendElement(NULL, returnList, Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))); + gotFilename |= (Tcl_DStringLength(&ds) > 0); } Tcl_SetObjResult(interp, returnList); Tcl_DStringFree(&ds); } else { Tcl_AppendResult(interp, ConvertExternalFilename(unicodeEncoding, (char *) ofn.lpstrFile, &ds), NULL); + gotFilename = (Tcl_DStringLength(&ds) > 0); Tcl_DStringFree(&ds); } result = TCL_OK; - if ((ofn.nFilterIndex > 0) && - Tcl_GetCharLength(Tcl_GetObjResult(interp)) > 0 && - typeVariableObj && filterObj) { + if ((ofn.nFilterIndex > 0) && gotFilename && typeVariableObj + && filterObj) { int listObjc, count; Tcl_Obj **listObjv = NULL; Tcl_Obj **typeInfo = NULL; |