diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-10-22 10:27:58 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-10-22 10:27:58 (GMT) |
commit | da76bd4e71a3e8d17bd2b649d285e19a41f834b3 (patch) | |
tree | fe5c722a73092bba1b18f4ddcc412eaf45298fd1 /win/tkWinDialog.c | |
parent | 4da8735aec87cdbfff2fe507c403b4a4bf242f2e (diff) | |
download | tk-da76bd4e71a3e8d17bd2b649d285e19a41f834b3.zip tk-da76bd4e71a3e8d17bd2b649d285e19a41f834b3.tar.gz tk-da76bd4e71a3e8d17bd2b649d285e19a41f834b3.tar.bz2 |
Deal with [Patch 2168768], so making the -typevariable option work consistently
with global variables (the only way it *can* work...)
Diffstat (limited to 'win/tkWinDialog.c')
-rw-r--r-- | win/tkWinDialog.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 5cd1a4d..93d81b6 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinDialog.c,v 1.50.2.3 2009/04/24 17:30:33 hobbs Exp $ + * RCS: @(#) $Id: tkWinDialog.c,v 1.50.2.4 2009/10/22 10:27:58 dkf Exp $ * */ @@ -702,7 +702,8 @@ GetFileNameW( break; case FILE_TYPEVARIABLE: typeVariableObj = valuePtr; - initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, 0); + initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, + TCL_GLOBAL_ONLY); break; } } @@ -881,24 +882,26 @@ GetFileNameW( (char *) ofn.lpstrFile, &ds), NULL); Tcl_DStringFree(&ds); } + result = TCL_OK; if ((ofn.nFilterIndex > 0) && Tcl_GetCharLength(Tcl_GetObjResult(interp)) > 0 && typeVariableObj && filterObj) { int listObjc, count; Tcl_Obj **listObjv = NULL; Tcl_Obj **typeInfo = NULL; + if (Tcl_ListObjGetElements(interp, filterObj, - &listObjc, &listObjv) != TCL_OK) { + &listObjc, &listObjv) != TCL_OK) { result = TCL_ERROR; } else if (Tcl_ListObjGetElements(interp, - listObjv[ofn.nFilterIndex - 1], - &count, &typeInfo) != TCL_OK) { + listObjv[ofn.nFilterIndex - 1], + &count, &typeInfo) != TCL_OK) { + result = TCL_ERROR; + } else if (Tcl_ObjSetVar2(interp, typeVariableObj, NULL, + typeInfo[0], TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; - } else { - Tcl_ObjSetVar2(interp, typeVariableObj, NULL, typeInfo[0], 0); } } - result = TCL_OK; } else { /* * Use the CommDlgExtendedError() function to retrieve the error code. @@ -1144,7 +1147,8 @@ GetFileNameA( break; case FILE_TYPEVARIABLE: typeVariableObj = valuePtr; - initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, 0); + initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, + TCL_GLOBAL_ONLY); break; } } @@ -1330,24 +1334,26 @@ GetFileNameA( (char *) ofn.lpstrFile, &ds), NULL); Tcl_DStringFree(&ds); } + result = TCL_OK; if ((ofn.nFilterIndex > 0) && (Tcl_GetCharLength(Tcl_GetObjResult(interp)) > 0) && typeVariableObj && filterObj) { int listObjc, count; Tcl_Obj **listObjv = NULL; Tcl_Obj **typeInfo = NULL; + if (Tcl_ListObjGetElements(interp, filterObj, - &listObjc, &listObjv) != TCL_OK) { + &listObjc, &listObjv) != TCL_OK) { result = TCL_ERROR; } else if (Tcl_ListObjGetElements(interp, - listObjv[ofn.nFilterIndex - 1], - &count, &typeInfo) != TCL_OK) { + listObjv[ofn.nFilterIndex - 1], + &count, &typeInfo) != TCL_OK) { + result = TCL_ERROR; + } else if (Tcl_ObjSetVar2(interp, typeVariableObj, NULL, + typeInfo[0], TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; - } else { - Tcl_ObjSetVar2(interp, typeVariableObj, NULL, typeInfo[0], 0); } } - result = TCL_OK; } else { /* * Use the CommDlgExtendedError() function to retrieve the error code. |