Tk Source Code

Check-in [1cb7c1e0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Better fix for bug-1630262, also fixing bug-1615425
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-1630262
Files: files | file ages | folders
SHA1: 1cb7c1e06a59d16c3cfbd413dc552679427f1576
User & Date: fvogel 2012-02-02 10:40:12
Context
2012-02-03
21:04
Added test for bug 1615425 check-in: e4f27e1d user: fvogel tags: bug-1630262
2012-02-02
10:40
Better fix for bug-1630262, also fixing bug-1615425 check-in: 1cb7c1e0 user: fvogel tags: bug-1630262
2012-01-31
22:24
[Bug-1630262]: segfault when deleting lines with peer text widgets check-in: abca82f4 user: fvogel tags: bug-1630262
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkTextBTree.c.

1987
1988
1989
1990
1991
1992
1993
1994










1995








1996



1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
		nodePtr2 = nodePtr2->nextPtr) {
	    if (nodePtr2 == NULL) {
		Tcl_Panic("TkBTreeLinesTo couldn't find node");
	    }
	    index += nodePtr2->numLines;
	}
    }
    if (textPtr != NULL && textPtr->start != NULL) {










	index -= TkBTreeLinesTo(NULL, textPtr->start);








        if (index < 0) {



            /* One should panic here!
            Tcl_Panic("TkBTreeLinesTo: linePtr comes before -startline");
             */
        }
    }
    return index;
}

/*
 *----------------------------------------------------------------------
 *
 * TkBTreeLinkSegment --
 *
 *	This function adds a new segment to a B-tree at a given location.
 *







|
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
|
>
>
>
|
|
<




|







1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019

2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
		nodePtr2 = nodePtr2->nextPtr) {
	    if (nodePtr2 == NULL) {
		Tcl_Panic("TkBTreeLinesTo couldn't find node");
	    }
	    index += nodePtr2->numLines;
	}
    }
    if (textPtr != NULL) {
        /* 
         * The index to return must be relative to textPtr, not to the entire
         * tree. Take care to never return a negative index when linePtr
         * denotes a line before -startline, or an index larger than the
         * number of lines in textPtr when linePtr is a line past -endline.
         */

        int indexStart, indexEnd;

        if (textPtr->start != NULL) {
            indexStart = TkBTreeLinesTo(NULL, textPtr->start);
        } else {
            indexStart = 0;
        }
        if (textPtr->end != NULL) {
            indexEnd = TkBTreeLinesTo(NULL, textPtr->end);
        } else {
            indexEnd = TkBTreeNumLines(textPtr->sharedTextPtr->tree, NULL);
        }
        if (index < indexStart) {
            index = 0;
        } else if (index > indexEnd) {
            index = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
        } else {
            index -= indexStart;

        }
    }
    return index;
}

/*
 *----------------------------------------------------------------------
 *
 * TkBTreeLinkSegment --
 *
 *	This function adds a new segment to a B-tree at a given location.
 *

Changes to generic/tkTextDisp.c.

3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
    int lineCount,		/* And includes this many following lines. */
    int action)			/* Indicates what type of invalidation
				 * occurred (insert, delete, or simple). */
{
    int fromLine;
    TextDInfo *dInfoPtr = textPtr->dInfoPtr;

    /*
     * All lines to invalidate must be inside the -startline/-endline range.
     */

    if (linePtr != NULL) {
        int start;
        TkTextLine *toLinePtr;
        if (textPtr->start != NULL) {
            fromLine = TkBTreeLinesTo(NULL, linePtr);
            start = TkBTreeLinesTo(NULL, textPtr->start);
            if (fromLine < start) {
                lineCount -= start - fromLine;
                linePtr = textPtr->start;
            }
        }
        if (textPtr->end != NULL) {
            int count = 0;
            toLinePtr = linePtr;
            while (count < lineCount && toLinePtr != NULL) {
                toLinePtr = TkBTreeNextLine(textPtr, toLinePtr);
                count++;
            }
            if (toLinePtr == NULL) {
                lineCount = count;
            }
        }
    }

    if (linePtr != NULL) {
	int counter = lineCount;

	fromLine = TkBTreeLinesTo(textPtr, linePtr);

	/*
	 * Invalidate the height calculations of each line in the given range.







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







3215
3216
3217
3218
3219
3220
3221




























3222
3223
3224
3225
3226
3227
3228
    int lineCount,		/* And includes this many following lines. */
    int action)			/* Indicates what type of invalidation
				 * occurred (insert, delete, or simple). */
{
    int fromLine;
    TextDInfo *dInfoPtr = textPtr->dInfoPtr;





























    if (linePtr != NULL) {
	int counter = lineCount;

	fromLine = TkBTreeLinesTo(textPtr, linePtr);

	/*
	 * Invalidate the height calculations of each line in the given range.