From 20e5273f5b6208576bf9bc900e4cff39d724cb7f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 5 Dec 2015 13:31:00 +0000 Subject: Fix for bug [ff8a1e55a2] - Filling a never-mapped text widget is CPU hungry - Patch from Koen Danckaert --- generic/tkTextDisp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cfe6e7a..0665ba7 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2923,7 +2923,8 @@ AsyncUpdateLineMetrics( return; } - if (dInfoPtr->flags & REDRAW_PENDING) { + if ((dInfoPtr->flags & REDRAW_PENDING) || !Tk_IsMapped(textPtr->tkwin) + || dInfoPtr->maxX <= dInfoPtr->x || dInfoPtr->maxY <= dInfoPtr->y) { dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, clientData); return; -- cgit v0.12 From c1c79b52233b43b276d2b2933dade1563b16f0c5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Dec 2015 21:29:13 +0000 Subject: Reverted [d29847c6] since there is a better patch --- generic/tkTextDisp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 0665ba7..cfe6e7a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2923,8 +2923,7 @@ AsyncUpdateLineMetrics( return; } - if ((dInfoPtr->flags & REDRAW_PENDING) || !Tk_IsMapped(textPtr->tkwin) - || dInfoPtr->maxX <= dInfoPtr->x || dInfoPtr->maxY <= dInfoPtr->y) { + if (dInfoPtr->flags & REDRAW_PENDING) { dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, clientData); return; -- cgit v0.12 From 7aa2342349dcaec45b76ecf2f5c6b0fe8ec33ae1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Dec 2015 21:36:25 +0000 Subject: Better patch for bug [ff8a1e55a2] - Filling a never-mapped text widget is CPU hungry - Patch from Koen Danckaert --- generic/tkTextDisp.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cfe6e7a..8a9d0e8 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -658,17 +658,8 @@ TkTextCreateDInfo( dInfoPtr->metricEpoch = -1; dInfoPtr->metricIndex.textPtr = NULL; dInfoPtr->metricIndex.linePtr = NULL; - - /* - * Add a refCount for each of the idle call-backs. - */ - - textPtr->refCount++; - dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(0, - AsyncUpdateLineMetrics, (ClientData) textPtr); - textPtr->refCount++; - dInfoPtr->scrollbarTimer = Tcl_CreateTimerHandler(200, - AsyncUpdateYScrollbar, (ClientData) textPtr); + dInfoPtr->lineUpdateTimer = NULL; + dInfoPtr->scrollbarTimer = NULL; textPtr->dInfoPtr = dInfoPtr; } @@ -2912,9 +2903,10 @@ AsyncUpdateLineMetrics( dInfoPtr->lineUpdateTimer = NULL; - if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { + if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED) + || !Tk_IsMapped(textPtr->tkwin)) { /* - * The widget has been deleted. Don't do anything. + * The widget has been deleted, or is not mapped. Don't do anything. */ if (--textPtr->refCount == 0) { -- cgit v0.12