summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2003-11-07 12:06:47 (GMT)
committervincentdarley <vincentdarley>2003-11-07 12:06:47 (GMT)
commit72a88aa5cae0b9f4103d5cab3da7085f3f4ada3d (patch)
tree617942b27e4145ce929f01bbc318fd08728b8945
parent76c9825c10877956d64e567a67185cc2690c547d (diff)
downloadtk-72a88aa5cae0b9f4103d5cab3da7085f3f4ada3d.zip
tk-72a88aa5cae0b9f4103d5cab3da7085f3f4ada3d.tar.gz
tk-72a88aa5cae0b9f4103d5cab3da7085f3f4ada3d.tar.bz2
another elide/tkchat/tkTextDisp.c fix
-rw-r--r--ChangeLog6
-rw-r--r--generic/tkTextDisp.c25
-rw-r--r--tests/textDisp.test27
3 files changed, 52 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index dc6ca84..0ae431c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-11-07 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * tests/textDisp.test:
+ * generic/tkTextDisp.c: fix to another version of [Bug 833627]
+ (crash in tkchat), adding two new tests.
+
2003-11-05 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* library/demos/nl.msg: Dutch messages from Arjen Markus [Patch 836368]
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 08680f9..ebe9b4c 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextDisp.c,v 1.22 2003/11/03 16:10:12 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.23 2003/11/07 12:06:47 vincentdarley Exp $
*/
#include "tkPort.h"
@@ -955,6 +955,7 @@ LayoutDLine(textPtr, indexPtr)
*/
elide = TkTextIsElided(textPtr, indexPtr); /* save a malloc */
if (elide && indexPtr->byteIndex==0) {
+ int tagElidePriority = -1;
maxBytes = 0;
for (segPtr = indexPtr->linePtr->segPtr;
segPtr != NULL;
@@ -969,11 +970,25 @@ LayoutDLine(textPtr, indexPtr)
break;
}
maxBytes += segPtr->size;
+ /*
+ * Reset tag elide priority, since we're on a new
+ * character.
+ */
+ tagElidePriority = -1;
} else if ((segPtr->typePtr == &tkTextToggleOffType)
- || (segPtr->typePtr == &tkTextToggleOnType)) {
- if (segPtr->body.toggle.tagPtr->elideString != NULL) {
- elide = (segPtr->typePtr == &tkTextToggleOffType)
- ^ segPtr->body.toggle.tagPtr->elide;
+ || (segPtr->typePtr == &tkTextToggleOnType)) {
+ TkTextTag *tagPtr = segPtr->body.toggle.tagPtr;
+ if (tagPtr->elideString != NULL) {
+ /*
+ * Only update the elide status if this tag has
+ * higher priority than any other we've so far
+ * seen at this index.
+ */
+ if (tagPtr->priority > tagElidePriority) {
+ elide = ((segPtr->typePtr == &tkTextToggleOffType)
+ ^ tagPtr->elide);
+ tagElidePriority = tagPtr->priority;
+ }
}
}
}
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 49dbe1b..abf1d2a 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: textDisp.test,v 1.14 2003/11/04 23:37:51 vincentdarley Exp $
+# RCS: @(#) $Id: textDisp.test,v 1.15 2003/11/07 12:06:47 vincentdarley Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -161,6 +161,31 @@ test textDisp-0.2 {double tag elide transition} {
destroy .top
} {}
+test textDisp-0.3 {double tag elide transition} {
+ catch {destroy .txt}
+ pack [text .txt]
+ # Note that TRAFFIC should have a higher priority than SYSTEM
+ # in terms of the tag effects.
+ .txt tag configure SYSTEM -elide 0
+ .txt tag configure TRAFFIC -elide 1
+ .txt insert end "\n" {TRAFFIC SYSTEM}
+ update
+ destroy .txt
+} {}
+
+test textDisp-0.4 {double tag elide transition} {
+ catch {destroy .txt}
+ pack [text .txt]
+ # Note that TRAFFIC should have a higher priority than SYSTEM
+ # in terms of the tag effects.
+ .txt tag configure SYSTEM -elide 0
+ .txt tag configure TRAFFIC -elide 1
+ .txt insert end "\n" {SYSTEM TRAFFIC}
+ # Crash was here.
+ update
+ destroy .txt
+} {}
+
test textDisp-1.1 {GetStyle procedure, priorities and tab stops} {
.t delete 1.0 end
.t insert 1.0 "x\ty"