From 5ed89c6ce021c3a02c484f7800ec01fab6d5e3c3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Jan 2013 14:54:19 +0000 Subject: make TkBackgroundEvalObjv a static function, and eliminate the use of the deprecated SaveResult API from it. --- generic/tkUtil.c | 83 ------------------------------------------------- macosx/tkMacOSXDialog.c | 65 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 83 deletions(-) diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 2a8240b..bfa5d5c 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -976,89 +976,6 @@ TkFindStateNumObj( } /* - * ---------------------------------------------------------------------- - * - * 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_DString errorInfo, errorCode; - Tcl_SavedResult state; - int n, r = TCL_OK; - - Tcl_DStringInit(&errorInfo); - Tcl_DStringInit(&errorCode); - - Tcl_Preserve(interp); - - /* - * Record the state of the interpreter - */ - - Tcl_SaveResult(interp, &state); - Tcl_DStringAppend(&errorInfo, - Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY), -1); - Tcl_DStringAppend(&errorCode, - Tcl_GetVar(interp, "errorCode", TCL_GLOBAL_ONLY), -1); - - /* - * 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); - } - - Tcl_Release(interp); - - /* - * Restore the state of the interpreter - */ - - Tcl_SetVar(interp, "errorInfo", - Tcl_DStringValue(&errorInfo), TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "errorCode", - Tcl_DStringValue(&errorCode), TCL_GLOBAL_ONLY); - Tcl_RestoreResult(interp, &state); - - /* - * Clean up references. - */ - - Tcl_DStringFree(&errorInfo); - Tcl_DStringFree(&errorCode); - - return r; -} - -/* * Local Variables: * mode: c * c-basic-offset: 4 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 -- cgit v0.12 From 133b3139d9c61a6c78f5dcd0e704f110cb269b1b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Jan 2013 15:17:02 +0000 Subject: Tk_CancelIdleCall -> Tcl_CancelIdleCall --- generic/ttk/ttkManager.c | 2 +- macosx/tkMacOSXWm.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index ba9e5c0..2fcb190 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -237,7 +237,7 @@ void Ttk_DeleteManager(Ttk_Manager *mgr) ckfree((ClientData)mgr->slaves); } - Tk_CancelIdleCall(ManagerIdleProc, mgr); + Tcl_CancelIdleCall(ManagerIdleProc, mgr); ckfree((ClientData)mgr); } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index cb6e3c4..fbc167d 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -669,7 +669,7 @@ TkWmMapWindow( wmPtr->flags |= WM_ABOUT_TO_MAP; if (wmPtr->flags & WM_UPDATE_PENDING) { - Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); + Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } UpdateGeometryInfo(winPtr); wmPtr->flags &= ~WM_ABOUT_TO_MAP; @@ -773,7 +773,7 @@ TkWmDeadWindow( ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { - Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); + Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } /* @@ -4400,7 +4400,7 @@ Tk_MoveToplevelWindow( if (!(wmPtr->flags & WM_NEVER_MAPPED)) { if (wmPtr->flags & WM_UPDATE_PENDING) { - Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); + Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } UpdateGeometryInfo(winPtr); } -- cgit v0.12