summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-23 14:54:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-23 14:54:19 (GMT)
commit5ed89c6ce021c3a02c484f7800ec01fab6d5e3c3 (patch)
tree75d5eb2735b3c6b0431e3874187c373c3fa67f87 /macosx
parent8faee2bb6cd4206d77f37e8dffaae0adb9df40d0 (diff)
downloadtk-5ed89c6ce021c3a02c484f7800ec01fab6d5e3c3.zip
tk-5ed89c6ce021c3a02c484f7800ec01fab6d5e3c3.tar.gz
tk-5ed89c6ce021c3a02c484f7800ec01fab6d5e3c3.tar.bz2
make TkBackgroundEvalObjv a static function, and eliminate the use of the deprecated SaveResult API from it.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXDialog.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index d9e824a..bc11b96 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -14,6 +14,9 @@
#include "tkMacOSXPrivate.h"
#include "tkFileFilter.h"
+static int TkBackgroundEvalObjv(Tcl_Interp *interp, int objc,
+ Tcl_Obj *const *objv, int flags);
+
static const char *colorOptionStrings[] = {
"-initialcolor", "-parent", "-title", NULL
};
@@ -1057,6 +1060,68 @@ end:
}
/*
+ * ----------------------------------------------------------------------
+ *
+ * TkBackgroundEvalObjv --
+ *
+ * Evaluate a command while ensuring that we do not affect the
+ * interpreters state. This is important when evaluating script
+ * during background tasks.
+ *
+ * Results:
+ * A standard Tcl result code.
+ *
+ * Side Effects:
+ * The interpreters variables and code may be modified by the script
+ * but the result will not be modified.
+ *
+ * ----------------------------------------------------------------------
+ */
+
+int
+TkBackgroundEvalObjv(
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const *objv,
+ int flags)
+{
+ Tcl_InterpState state;
+ int n, r = TCL_OK;
+
+ /*
+ * Record the state of the interpreter.
+ */
+
+ Tcl_Preserve(interp);
+ state = Tcl_SaveInterpState(interp, TCL_OK);
+
+ /*
+ * Evaluate the command and handle any error.
+ */
+
+ for (n = 0; n < objc; ++n) {
+ Tcl_IncrRefCount(objv[n]);
+ }
+ r = Tcl_EvalObjv(interp, objc, objv, flags);
+ for (n = 0; n < objc; ++n) {
+ Tcl_DecrRefCount(objv[n]);
+ }
+ if (r == TCL_ERROR) {
+ Tcl_AddErrorInfo(interp, "\n (background event handler)");
+ Tcl_BackgroundError(interp);
+ }
+
+ /*
+ * Restore the state of the interpreter.
+ */
+
+ (void) Tcl_RestoreInterpState(interp, state);
+ Tcl_Release(interp);
+
+ return r;
+}
+
+/*
* Local Variables:
* mode: objc
* c-basic-offset: 4