summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-04-12 10:06:09 (GMT)
committerhobbs <hobbs>2002-04-12 10:06:09 (GMT)
commit8e510069debe72b6010098ecdac9867c534a5c6e (patch)
treedcc25f95c8ad275eff78ab29937f2130a80faa0d
parent197b4b9a5236ad16a01f09f391f3e5a46decab27 (diff)
downloadtk-8e510069debe72b6010098ecdac9867c534a5c6e.zip
tk-8e510069debe72b6010098ecdac9867c534a5c6e.tar.gz
tk-8e510069debe72b6010098ecdac9867c534a5c6e.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.
-rw-r--r--generic/tkInt.h7
-rw-r--r--unix/tkUnixXId.c57
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);
}
/*