summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2006-09-25 14:58:00 (GMT)
committerKevin B Kenny <kennykb@acm.org>2006-09-25 14:58:00 (GMT)
commit85db18a56024363297104710a26f2ab0d7d765a5 (patch)
treef70a40118296664949715b07d9b25ff9b2d2190f /generic
parente293e4aa3ac622c6b6b896d4726462c22a5c297f (diff)
downloadtcl-85db18a56024363297104710a26f2ab0d7d765a5.zip
tcl-85db18a56024363297104710a26f2ab0d7d765a5.tar.gz
tcl-85db18a56024363297104710a26f2ab0d7d765a5.tar.bz2
yet another stab at 1564777
Diffstat (limited to 'generic')
-rw-r--r--generic/tclNotify.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/generic/tclNotify.c b/generic/tclNotify.c
index 56dca6a..6263b41 100644
--- a/generic/tclNotify.c
+++ b/generic/tclNotify.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNotify.c,v 1.22 2006/09/25 13:35:10 dgp Exp $
+ * RCS: @(#) $Id: tclNotify.c,v 1.23 2006/09/25 14:58:03 kennykb Exp $
*/
#include "tclInt.h"
@@ -522,33 +522,53 @@ Tcl_DeleteEvents(
Tcl_EventDeleteProc *proc, /* The function to call. */
ClientData clientData) /* The type-specific data. */
{
- Tcl_Event *evPtr, *prevPtr, *hold;
+ Tcl_Event *evPtr; /* Pointer to the event being examined */
+ Tcl_Event *prevPtr; /* Pointer to evPtr's predecessor, or NULL
+ * if evPtr designates the first event in the
+ * queue for the thread */
+ Tcl_Event* hold;
+
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
Tcl_MutexLock(&(tsdPtr->queueMutex));
- for (prevPtr=NULL, evPtr=tsdPtr->firstEventPtr; evPtr!=NULL; ) {
+
+ /* Walk the queue of events for the thread, applying 'proc' to each */
+
+ prevPtr = NULL;
+ evPtr = tsdPtr->firstEventPtr;
+ while (evPtr != NULL) {
if ((*proc) (evPtr, clientData) == 1) {
- if (tsdPtr->firstEventPtr == evPtr) {
+
+ /* This event should be deleted. Unlink it. */
+
+ if (prevPtr == NULL) {
tsdPtr->firstEventPtr = evPtr->nextPtr;
} else {
- if (prevPtr == NULL) {
- Tcl_Panic("badly connected event list");
- } else {
- prevPtr->nextPtr = evPtr->nextPtr;
- }
+ prevPtr->nextPtr = evPtr->nextPtr;
}
+
+ /* Update 'last' and 'marker' events if either has been deleted. */
+
if (evPtr->nextPtr == NULL) {
tsdPtr->lastEventPtr = prevPtr;
}
if (tsdPtr->markerEventPtr == evPtr) {
tsdPtr->markerEventPtr = prevPtr;
}
+
+ /* Delete the event data structure. */
+
hold = evPtr;
evPtr = evPtr->nextPtr;
ckfree((char *) hold);
+
} else {
+
+ /* Event is to be retained. */
+
prevPtr = evPtr;
evPtr = evPtr->nextPtr;
+
}
}
Tcl_MutexUnlock(&(tsdPtr->queueMutex));