summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2004-01-07 16:28:23 (GMT)
committervincentdarley <vincentdarley>2004-01-07 16:28:23 (GMT)
commit9c5f4049da417ed02b8a48adcc61ff8f88bfce2e (patch)
tree182b6e90e0039b2a56b8eff89176999a750beb26 /generic
parent4bed7923e3d13f9f4e7841c45e3ecfca69d74961 (diff)
downloadtk-9c5f4049da417ed02b8a48adcc61ff8f88bfce2e.zip
tk-9c5f4049da417ed02b8a48adcc61ff8f88bfce2e.tar.gz
tk-9c5f4049da417ed02b8a48adcc61ff8f88bfce2e.tar.bz2
fix to text widget yview bug
Diffstat (limited to 'generic')
-rw-r--r--generic/tkTextBTree.c10
-rw-r--r--generic/tkTextDisp.c16
2 files changed, 20 insertions, 6 deletions
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index b2db5aa..8ac05ea 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextBTree.c,v 1.11 2003/12/15 11:51:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextBTree.c,v 1.12 2004/01/07 16:28:23 vincentdarley Exp $
*/
#include "tkInt.h"
@@ -1002,6 +1002,10 @@ TkBTreeFindPixelLine(tree, pixels, pixelOffset)
return NULL;
}
+ if (nodePtr->numPixels == 0) {
+ panic("TkBTreeFindPixelLine called with empty window");
+ }
+
/*
* Work down through levels of the tree until a node is found at
* level 0.
@@ -1012,7 +1016,7 @@ TkBTreeFindPixelLine(tree, pixels, pixelOffset)
nodePtr->numPixels <= pixelsLeft;
nodePtr = nodePtr->nextPtr) {
if (nodePtr == NULL) {
- panic("TkBTreeFindLine ran out of nodes");
+ panic("TkBTreeFindPixelLine ran out of nodes");
}
pixelsLeft -= nodePtr->numPixels;
}
@@ -1026,7 +1030,7 @@ TkBTreeFindPixelLine(tree, pixels, pixelOffset)
linePtr->pixelHeight < pixelsLeft;
linePtr = linePtr->nextPtr) {
if (linePtr == NULL) {
- panic("TkBTreeFindLine ran out of lines");
+ panic("TkBTreeFindPixelLine ran out of lines");
}
pixelsLeft -= linePtr->pixelHeight;
}
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 1fbf4cf..9cab7f8 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.38 2003/12/15 11:51:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.39 2004/01/07 16:28:23 vincentdarley Exp $
*/
#include "tkPort.h"
@@ -5193,14 +5193,23 @@ TkTextYviewCmd(textPtr, interp, objc, objv)
switch (type) {
case TKTEXT_SCROLL_ERROR:
return TCL_ERROR;
- case TKTEXT_SCROLL_MOVETO:
+ case TKTEXT_SCROLL_MOVETO: {
+ int numPixels = TkBTreeNumPixels(textPtr->tree);
+ if (numPixels == 0) {
+ /*
+ * If the window is totally empty no scrolling is
+ * needed, and the TkTextMakePixelIndex call
+ * below will fail.
+ */
+ break;
+ }
if (fraction > 1.0) {
fraction = 1.0;
}
if (fraction < 0) {
fraction = 0;
}
- fraction *= (TkBTreeNumPixels(textPtr->tree)-1);
+ fraction *= (numPixels - 1);
/*
* This function returns the number of pixels by which the
* given line should overlap the top of the visible screen.
@@ -5211,6 +5220,7 @@ TkTextYviewCmd(textPtr, interp, objc, objv)
(int) (0.5 + fraction), &index);
TkTextSetYView(textPtr, &index, pixels);
break;
+ }
case TKTEXT_SCROLL_PAGES: {
/*
* Scroll up or down by screenfuls. Actually, use the