diff options
author | hobbs <hobbs@noemail.net> | 2002-04-12 10:06:08 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2002-04-12 10:06:08 (GMT) |
commit | 14bacff798aece3ecbbd6724eb82e94a58ca3faa (patch) | |
tree | dcc25f95c8ad275eff78ab29937f2130a80faa0d | |
parent | a052dc724331f3d77a0b447008a808eb8313f576 (diff) | |
download | tk-14bacff798aece3ecbbd6724eb82e94a58ca3faa.zip tk-14bacff798aece3ecbbd6724eb82e94a58ca3faa.tar.gz tk-14bacff798aece3ecbbd6724eb82e94a58ca3faa.tar.bz2 |
* generic/tkInt.h:
* unix/tkUnixXId.c (TkFreeXId): frees XID resources.
Made idCleanupScheduled a Tcl_TimerToken (was int) in TkDisplay
structure to allow us to delete the timer scheduled for it.
FossilOrigin-Name: e28c2458d8421ff25ad2a2ebb582a572176e4e56
-rw-r--r-- | generic/tkInt.h | 7 | ||||
-rw-r--r-- | unix/tkUnixXId.c | 57 |
2 files changed, 54 insertions, 10 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h index 44c9f67..75ac87f 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: $Id: tkInt.h,v 1.43 2002/04/05 08:41:07 hobbs Exp $ + * RCS: $Id: tkInt.h,v 1.44 2002/04/12 10:06:09 hobbs Exp $ */ #ifndef _TKINT @@ -423,8 +423,9 @@ typedef struct TkDisplay { /* First in list of chunks of window * identifers that can't be reused right * now. */ - int idCleanupScheduled; /* 1 means a call to WindowIdCleanup has - * already been scheduled, 0 means it + Tcl_TimerToken idCleanupScheduled; + /* If set, it means a call to WindowIdCleanup + * has already been scheduled, 0 means it * hasn't. */ /* diff --git a/unix/tkUnixXId.c b/unix/tkUnixXId.c index c2be145..9f3dd82 100644 --- a/unix/tkUnixXId.c +++ b/unix/tkUnixXId.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixXId.c,v 1.6 2001/09/25 16:25:20 dgp Exp $ + * RCS: @(#) $Id: tkUnixXId.c,v 1.7 2002/04/12 10:06:09 hobbs Exp $ */ /* @@ -84,7 +84,50 @@ TkInitXId(dispPtr) dispPtr->display->resource_alloc; dispPtr->display->resource_alloc = AllocXId; dispPtr->windowStackPtr = NULL; - dispPtr->idCleanupScheduled = 0; + dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0; +} + +/* + *---------------------------------------------------------------------- + * + * TkFreeXId -- + * + * This procedure is called to free resources for the id allocator + * for a given display. + * + * Results: + * None. + * + * Side effects: + * Frees the id and window stack pools. + * + *---------------------------------------------------------------------- + */ + +void +TkFreeXId(dispPtr) + TkDisplay *dispPtr; /* Tk's information about the + * display. */ +{ + TkIdStack *stackPtr, *freePtr; + + if (dispPtr->idCleanupScheduled) { + Tcl_DeleteTimerHandler(dispPtr->idCleanupScheduled); + } + + for (stackPtr = dispPtr->idStackPtr; stackPtr != NULL; ) { + freePtr = stackPtr; + stackPtr = stackPtr->nextPtr; + ckfree((char *) freePtr); + } + dispPtr->idStackPtr = NULL; + + for (stackPtr = dispPtr->windowStackPtr; stackPtr != NULL; ) { + freePtr = stackPtr; + stackPtr = stackPtr->nextPtr; + ckfree((char *) freePtr); + } + dispPtr->windowStackPtr = NULL; } /* @@ -293,8 +336,8 @@ TkFreeWindowId(dispPtr, w) */ if (!dispPtr->idCleanupScheduled) { - dispPtr->idCleanupScheduled = 1; - Tcl_CreateTimerHandler(100, WindowIdCleanup, (ClientData) dispPtr); + dispPtr->idCleanupScheduled = + Tcl_CreateTimerHandler(100, WindowIdCleanup, (ClientData) dispPtr); } } @@ -328,7 +371,7 @@ WindowIdCleanup(clientData) ClientData oldData; static Tcl_Time timeout = {0, 0}; - dispPtr->idCleanupScheduled = 0; + dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0; /* * See if it's safe to recycle the window ids. It's safe if: @@ -375,8 +418,8 @@ WindowIdCleanup(clientData) */ tryAgain: - dispPtr->idCleanupScheduled = 1; - Tcl_CreateTimerHandler(500, WindowIdCleanup, (ClientData) dispPtr); + dispPtr->idCleanupScheduled = + Tcl_CreateTimerHandler(500, WindowIdCleanup, (ClientData) dispPtr); } /* |