diff options
author | griffin <briang42@easystreet.net> | 2021-03-15 20:10:04 (GMT) |
---|---|---|
committer | griffin <briang42@easystreet.net> | 2021-03-15 20:10:04 (GMT) |
commit | 7dcc8131f3a23e47eb29322fd7c9ef2c691b925c (patch) | |
tree | d864f776cd4311dcaa34e0a718f1b44bb4a281b3 /generic | |
parent | 30cbe7c9a25fd9d16a74523fdcd39c4ee12a883f (diff) | |
download | tk-7dcc8131f3a23e47eb29322fd7c9ef2c691b925c.zip tk-7dcc8131f3a23e47eb29322fd7c9ef2c691b925c.tar.gz tk-7dcc8131f3a23e47eb29322fd7c9ef2c691b925c.tar.bz2 |
fix and testcase for ticket [9b6065d1fd]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkInt.h | 4 | ||||
-rw-r--r-- | generic/tkWindow.c | 29 |
2 files changed, 21 insertions, 12 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h index ee453ea..214dd71 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -701,6 +701,10 @@ typedef struct TkMainInfo { struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by * this process. */ Tcl_HashTable busyTable; /* Information used by [tk busy] command. */ + Tcl_CmdInfo *tclUpdateCmdPtr; + /* Saved Tcl [update] command, used to restore + * Tcl's version of [update] after Tk is shut + * down */ } TkMainInfo; /* diff --git a/generic/tkWindow.c b/generic/tkWindow.c index ac36440..403b97d 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -93,6 +93,7 @@ static const XSetWindowAttributes defAtts= { #define PASSMAINWINDOW 2 #define WINMACONLY 4 #define USEINITPROC 8 +#define SAVEUPDATECMD 16 /* better only be one of these! */ typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData); typedef struct { @@ -126,7 +127,7 @@ static const TkCmd commands[] = { {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, - {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE}, + {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE|SAVEUPDATECMD}, {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, {"wm", Tk_WmObjCmd, PASSMAINWINDOW}, @@ -199,8 +200,6 @@ static const TkCmd commands[] = { {NULL, NULL, 0} }; -static Tcl_CmdInfo *saveTclUpdateCmd = NULL; -static Tcl_ObjCmdProc *updateObjProc = NULL; /* * Forward declarations to functions defined later in this file: */ @@ -878,6 +877,7 @@ TkCreateMainWindow( Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS); mainPtr->strictMotif = 0; mainPtr->alwaysShowSelection = 0; + mainPtr->tclUpdateCmdPtr = NULL; if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); @@ -938,12 +938,12 @@ TkCreateMainWindow( } else { clientData = NULL; } - if (Tcl_GetCommandInfo(interp, cmdPtr->name, &cmdInfo)) { - if (cmdInfo.isNativeObjectProc && saveTclUpdateCmd == NULL) { - saveTclUpdateCmd = ckalloc(sizeof (Tcl_CmdInfo)); - *saveTclUpdateCmd = cmdInfo; - updateObjProc = cmdInfo.objProc; - } + if ((cmdPtr->flags & SAVEUPDATECMD) && + Tcl_GetCommandInfo(interp, cmdPtr->name, &cmdInfo) && + cmdInfo.isNativeObjectProc && + mainPtr->tclUpdateCmdPtr == NULL) { + mainPtr->tclUpdateCmdPtr = ckalloc(sizeof (Tcl_CmdInfo)); + *mainPtr->tclUpdateCmdPtr = cmdInfo; } if (cmdPtr->flags & USEINITPROC) { ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData); @@ -1509,10 +1509,12 @@ Tk_DestroyWindow( if ((winPtr->mainPtr->interp != NULL) && !Tcl_InterpDeleted(winPtr->mainPtr->interp)) { for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { - if (saveTclUpdateCmd && updateObjProc && - cmdPtr->objProc == Tk_UpdateObjCmd) { + if ((cmdPtr->flags & SAVEUPDATECMD) && + winPtr->mainPtr->tclUpdateCmdPtr != NULL) { + /* Restore Tcl's version of [update] */ Tcl_CreateObjCommand(winPtr->mainPtr->interp, - cmdPtr->name, updateObjProc, + cmdPtr->name, + winPtr->mainPtr->tclUpdateCmdPtr->objProc, NULL, NULL); } else { Tcl_CreateObjCommand(winPtr->mainPtr->interp, @@ -1543,6 +1545,9 @@ Tk_DestroyWindow( if (winPtr->flags & TK_EMBEDDED) { XSync(winPtr->display, False); } + if (winPtr->mainPtr->tclUpdateCmdPtr) { + ckfree(winPtr->mainPtr->tclUpdateCmdPtr); + } ckfree(winPtr->mainPtr); /* |