summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-02-28 15:29:23 (GMT)
committerculler <culler>2019-02-28 15:29:23 (GMT)
commit827393fdd0d40c400d800dbf3b042b48c8f3a692 (patch)
tree5adf7403872ba1b8c00bb5f12aabb5f952b0512d
parent25cab35e68932b15367a751414207d51a502e687 (diff)
downloadtk-827393fdd0d40c400d800dbf3b042b48c8f3a692.zip
tk-827393fdd0d40c400d800dbf3b042b48c8f3a692.tar.gz
tk-827393fdd0d40c400d800dbf3b042b48c8f3a692.tar.bz2
Fix bugs in the list management code for the record of transient windows.
-rw-r--r--macosx/tkMacOSXWm.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index ecb4456..599455d 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -3569,6 +3569,7 @@ WmTransientCmd(
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window master;
WmInfo *wmPtr2;
+ Transient *transient;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?master?");
@@ -3625,14 +3626,19 @@ WmTransientCmd(
}
/*
- * Add the transient to the master's list.
+ * Add the transient to the master's list, if it not already there.
*/
-
- Transient *transient = ckalloc(sizeof(Transient));
- transient->winPtr = winPtr;
- transient->flags = 0;
- transient->nextPtr = wmPtr2->transientPtr;
- wmPtr2->transientPtr = transient;
+
+ for (transient = wmPtr2->transientPtr;
+ transient != NULL && transient->winPtr != winPtr;
+ transient = transient->nextPtr) {}
+ if (transient == NULL) {
+ transient = ckalloc(sizeof(Transient));
+ transient->winPtr = winPtr;
+ transient->flags = 0;
+ transient->nextPtr = wmPtr2->transientPtr;
+ wmPtr2->transientPtr = transient;
+ }
/*
* If the master is withdrawn or iconic then withdraw the transient.
@@ -3676,6 +3682,8 @@ RemoveTransient(
{
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
TkWindow *masterPtr;
+ Transient *T, *temp;
+
if (wmPtr == NULL || wmPtr->master == NULL) {
return;
}
@@ -3685,18 +3693,23 @@ RemoveTransient(
return;
}
wmPtr->master = NULL;
- Transient *temp, *cursor = wmPtr2->transientPtr;
- if (cursor->winPtr == winPtr) {
- temp = cursor->nextPtr;
- ckfree(cursor);
- cursor = temp;
- masterPtr->wmInfoPtr->transientPtr = cursor;
- }
- while (cursor != NULL) {
- if (cursor->winPtr == winPtr) {
- temp = cursor->nextPtr;
- ckfree(cursor);
- cursor = temp;
+ T = wmPtr2->transientPtr;
+ while (T != NULL) {
+ if (T->winPtr != winPtr) {
+ break;
+ }
+ temp = T->nextPtr;
+ ckfree(T);
+ T = temp;
+ }
+ wmPtr2->transientPtr = T;
+ while (T != NULL) {
+ if (T->nextPtr && T->nextPtr->winPtr == winPtr) {
+ temp = T->nextPtr;
+ T->nextPtr = temp->nextPtr;
+ ckfree(temp);
+ } else {
+ T = T->nextPtr;
}
}
}