summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-09-20 22:59:40 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-09-20 22:59:40 (GMT)
commit468499bdecc1465a84240284ade36429012147e8 (patch)
treec03418956b7682e229796f5a2de8d36f866b4b8f
parente00b3f658a46280b2a4e638171b8d64100182385 (diff)
downloadtk-468499bdecc1465a84240284ade36429012147e8.zip
tk-468499bdecc1465a84240284ade36429012147e8.tar.gz
tk-468499bdecc1465a84240284ade36429012147e8.tar.bz2
Only call callbacks that are not NULL. [Bug 1791052]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkTextDisp.c11
-rw-r--r--tests/textDisp.test41
3 files changed, 42 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f895ff..681f4fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-20 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tkTextDisp.c (LayoutDLine): Only call callbacks that are
+ * tests/textDisp.test (textDisp-32.3): not NULL. [Bug 1791052]
+
2007-09-20 Don Porter <dgp@users.sourceforge.net>
*** 8.5b1 TAGGED FOR RELEASE ***
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index d5d827d..7e43bf1 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -12,7 +12,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.65 2007/09/07 00:34:54 dgp Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.66 2007/09/20 22:59:40 dkf Exp $
*/
#include "tkInt.h"
@@ -1551,6 +1551,7 @@ LayoutDLine(
*/
TkTextLine *linePtr = TkBTreeNextLine(NULL, curIndex.linePtr);
+
if (linePtr != NULL) {
dlPtr->logicalLinesMerged++;
curIndex.byteIndex = 0;
@@ -1609,11 +1610,15 @@ LayoutDLine(
}
FreeStyle(textPtr, chunkPtr->stylePtr);
breakChunkPtr->nextPtr = chunkPtr->nextPtr;
- (*chunkPtr->undisplayProc)(textPtr, chunkPtr);
+ if (chunkPtr->undisplayProc != NULL) {
+ (*chunkPtr->undisplayProc)(textPtr, chunkPtr);
+ }
ckfree((char *) chunkPtr);
}
if (breakByteOffset != breakChunkPtr->numBytes) {
- (*breakChunkPtr->undisplayProc)(textPtr, breakChunkPtr);
+ if (breakChunkPtr->undisplayProc != NULL) {
+ (*breakChunkPtr->undisplayProc)(textPtr, breakChunkPtr);
+ }
segPtr = TkTextIndexToSeg(&breakIndex, &byteOffset);
(*segPtr->typePtr->layoutProc)(textPtr, &breakIndex,
segPtr, byteOffset, maxX, breakByteOffset, 0,
diff --git a/tests/textDisp.test b/tests/textDisp.test
index aa99a43..337b1ed 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.40 2006/03/23 16:26:12 dgp Exp $
+# RCS: @(#) $Id: textDisp.test,v 1.41 2007/09/20 22:59:41 dkf Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -3644,7 +3644,6 @@ test textDisp-32.0 {everything elided} {
update ; update ; update ; update
destroy .tt
} {}
-
test textDisp-32.1 {everything elided} {
# Must not crash
pack [text .tt]
@@ -3657,7 +3656,6 @@ test textDisp-32.1 {everything elided} {
update ; update ; update ; update
destroy .tt
} {}
-
test textDisp-32.2 {elide and tags} {
pack [text .tt -height 30 -width 100 -bd 0 \
-highlightthickness 0 -padx 0]
@@ -3675,7 +3673,6 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
# hide tag 1, remaining text should not be indented, since
# the indented tag and character is hidden.
.tt tag configure testtag1 -elide 1 ; update
@@ -3683,11 +3680,9 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
# reset
.tt tag configure testtag1 -lmargin1 0
.tt tag configure testtag1 -elide 0
-
# indent left margin of tag 2 by 20 pixels
# text should not be indented, since tag1 has lmargin1 of 0.
.tt tag configure testtag2 -lmargin1 20 ; update
@@ -3695,7 +3690,6 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
# hide tag 1, remaining text should now be indented, but
# the bbox of 1.0 should have zero width and zero indent,
# since it is elided at that position.
@@ -3704,11 +3698,9 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
# reset
.tt tag configure testtag2 -lmargin1 {}
.tt tag configure testtag1 -elide 0
-
# indent left margin of tag 3 by 20 pixels
# text should be indented, since this tag takes
# precedence over testtag1, and is applied to the
@@ -3718,7 +3710,6 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
# hide tag 1, remaining text should still be indented,
# since it still has testtag3 on it. Again the
# bbox of 1.0 should have 0.
@@ -3727,18 +3718,44 @@ test textDisp-32.2 {elide and tags} {
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
.tt tag configure testtag3 -lmargin1 {} -elide 0
.tt tag configure testtag1 -elide 1 -lmargin1 20
#7
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
-
destroy .tt
set res
} {{1.0 20 20} {1.29 0 0} {1.0 0 0} {1.29 0 20}\
{1.0 20 20} {1.29 0 20} {1.0 20 20}}
+test textDisp-32.3 "NULL undisplayProc problems: #1791052" -setup {
+ set img [image create photo -data {
+ R0lGODlhEgASANUAAAAAAP/////iHP/mIPrWDPraEP/eGPfOAPbKAPbOBPrS
+ CP/aFPbGAPLCAPLGAN62ANauAMylAPbCAPW/APK+AN6uALKNAPK2APK5ANal
+ AOyzArGHBZp3B+6uAHFVBFVACO6qAOqqAOalAMGMAbF+Am1QBG5QBeuiAOad
+ AM6NAJ9vBW1MBFlACFQ9CVlBCuaZAOKVANyVAZlpBMyFAKZtBJVhBEAUEP//
+ /wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADcALAAAAAASABIAAAa+
+ wJtw+Ckah0iiZwNhODKk0icp/HAShEKBoEBgVFOkK0Iw2GyCs+BAGbGIlrIt
+ EJjXBYgL6X3zJMx1Z2d3EyEmNx9xaYGCdwgaNEUPBYt0do4XKUUOlAOCnmcD
+ CwcXMZsEAgOqq6oLBY+mHxUKBqysCwQSIDNFJAidtgKjFyeRfRQHB2ipAmZs
+ IDArVSTIyoI2bB0oxkIsIxcNyeIXICh7SR8yIhoXFxogJzE1YegrNCkoLzM0
+ K/RUiEY+tKASBAA7
+ }]
+ destroy .tt
+} -body {
+ text .tt
+ .tt tag configure emoticon -elide 1
+ .tt insert end X
+ .tt mark set MSGLEFT "end - 1 char"
+ .tt mark gravity MSGLEFT left
+ .tt insert end ":)" emoticon
+ .tt image create end -image $img
+ pack .tt
+ update; update; update
+} -cleanup {
+ image delete $img
+ destroy .tt
+}
test textDisp-33.0 {one line longer than fits in the widget} {
pack [text .tt -wrap char]