From dcb68b1c9c9f143fc7459480396bf38a6a89d011 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 23 Dec 2015 11:29:34 +0000 Subject: Fixed bug [2f78c7c5ea] - text segfault with tablelist in TkBTreeLinesTo --- generic/tkTextDisp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ef8d6f4..b832443 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4803,9 +4803,15 @@ TextRedrawTag( /* * Round up the starting position if it's before the first line visible on - * the screen (we only care about what's on the screen). + * the screen (we only care about what's on the screen). Beware that the + * display info structure might need update, for instance if we arrived + * here after a delete operation triggering a trace running a tag removal + * covering the whole contents of the text widget. */ + if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { + UpdateDisplayInfo(textPtr); + } dlPtr = dInfoPtr->dLinePtr; if (dlPtr == NULL) { return; -- cgit v0.12 From 9e128a5e118f9b0ce894219129ba49b53f6cc3a8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 23 Dec 2015 16:36:56 +0000 Subject: Added new test textDisp-9.14 to check against regression regarding bug [2f78c7c5ea] --- tests/textDisp.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/textDisp.test b/tests/textDisp.test index 038eccd..ea4d0c2 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1333,6 +1333,30 @@ test textDisp-9.13 {TkTextRedrawTag} { update list $tk_textRelayout $tk_textRedraw } {{2.0 6.0 7.0} {2.0 6.0 7.0}} +test textDisp-9.14 {TkTextRedrawTag} { + pack [text .tnocrash] + for {set i 1} {$i < 6} {incr i} { + .tnocrash insert end \nfoo$i + } + .tnocrash tag configure mytag1 -relief raised + .tnocrash tag configure mytag2 -relief solid + update + proc doit {} { + .tnocrash tag add mytag1 4.0 5.0 + .tnocrash tag add mytag2 4.0 5.0 + after idle { + .tnocrash tag remove mytag1 1.0 end + .tnocrash tag remove mytag2 1.0 end + } + .tnocrash delete 1.0 2.0 + } + doit ; # must not crash + after 500 { + destroy .tnocrash + set done 1 + } + vwait done +} {} test textDisp-10.1 {TkTextRelayoutWindow} { .t configure -wrap char -- cgit v0.12 From a9da52862c63ba71773ced3f712e3565c2b3d81b Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 23 Dec 2015 16:43:16 +0000 Subject: Better comment about the fix, since the issue is now fully understood. --- generic/tkTextDisp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index b832443..133a7d7 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4805,8 +4805,9 @@ TextRedrawTag( * Round up the starting position if it's before the first line visible on * the screen (we only care about what's on the screen). Beware that the * display info structure might need update, for instance if we arrived - * here after a delete operation triggering a trace running a tag removal - * covering the whole contents of the text widget. + * here from an 'after idle' script removing tags in a range whose + * display lines (and dInfo) were partially invalidated by a previous + * delete operation in the text widget. */ if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { -- cgit v0.12