summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2012-02-10 15:54:25 (GMT)
committerdkf <dkf@noemail.net>2012-02-10 15:54:25 (GMT)
commit414bb88c98a945333ebd8004243a69bebe57e133 (patch)
tree831dac83c71f933f472362ac8526296f540174b3
parentf47a144c268184e3af5f8c4d46b580da68e995fb (diff)
parent010f9eeaf241dc2a57acde1596f372e6cff449bb (diff)
downloadtk-414bb88c98a945333ebd8004243a69bebe57e133.zip
tk-414bb88c98a945333ebd8004243a69bebe57e133.tar.gz
tk-414bb88c98a945333ebd8004243a69bebe57e133.tar.bz2
* win/tkWinDialog.c (GetFileName): 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: 1fff6f6ed9022153c2d67991a9adaf62b078b8fc
-rw-r--r--ChangeLog7
-rw-r--r--win/tkWinDialog.c13
2 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fd1f1c6..8233212 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-02-10 Donal K. Fellows <dkf@users.sf.net>
+
+ * win/tkWinDialog.c (GetFileName): 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
+
2012-01-29 Jan Nijtmans <nijtmans@users.sf.net>
* win/tkImgPhoto.c: [Bug 3480634]: PNG Images missing in menus on Mac
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index f26905b..9a6f76b 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -818,6 +818,11 @@ GetFileName(
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
@@ -854,6 +859,7 @@ GetFileName(
Tcl_AppendToObj(fullnameObj, "/", -1);
Tcl_AppendToObj(fullnameObj, Tcl_DStringValue(&filenameBuf),
Tcl_DStringLength(&filenameBuf));
+ gotFilename = 1;
Tcl_DStringFree(&filenameBuf);
Tcl_ListObjAppendElement(NULL, returnList, fullnameObj);
}
@@ -867,18 +873,19 @@ GetFileName(
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;