fix assertion failure by creating the line data, but not validating it at

2002-01-25  Havoc Pennington  <hp@redhat.com>

        * gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
        failure by creating the line data, but not validating it at this
        stage. Also, remove old code related to the "bogus newline" mess
        that removed all tags from the last char in the buffer if you
        tried to delete it.
        (_gtk_text_line_data_new): put this here and prepend underscore,
        remove from gtktextlayout.c
This commit is contained in:
Havoc Pennington 2002-01-29 04:55:48 +00:00 committed by Havoc Pennington
parent c5c5ff650d
commit 5d82c0a4b6
10 changed files with 108 additions and 91 deletions

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -1,3 +1,13 @@
2002-01-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): fix assertion
failure by creating the line data, but not validating it at this
stage. Also, remove old code related to the "bogus newline" mess
that removed all tags from the last char in the buffer if you
tried to delete it.
(_gtk_text_line_data_new): put this here and prepend underscore,
remove from gtktextlayout.c
Mon Jan 28 19:57:39 2002 Owen Taylor <otaylor@redhat.com>
* modules/input/imhangul.c modules/input/imhangul-defs.h

View File

@ -548,7 +548,7 @@ _gtk_text_btree_segments_changed (GtkTextBTree *tree)
void
_gtk_text_btree_delete (GtkTextIter *start,
GtkTextIter *end)
GtkTextIter *end)
{
GtkTextLineSegment *prev_seg; /* The segment just before the start
* of the deletion range. */
@ -575,64 +575,6 @@ _gtk_text_btree_delete (GtkTextIter *start,
if (gtk_debug_flags & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
{
/* FIXME this code should no longer be required */
/*
* The code below is ugly, but it's needed to make sure there
* is always a dummy empty line at the end of the text. If the
* final newline of the file (just before the dummy line) is being
* deleted, then back up index to just before the newline. If
* there is a newline just before the first character being deleted,
* then back up the first index too, so that an even number of lines
* gets deleted. Furthermore, remove any tags that are present on
* the newline that isn't going to be deleted after all (this simulates
* deleting the newline and then adding a "clean" one back again).
*/
gint line1;
gint line2;
line1 = gtk_text_iter_get_line (start);
line2 = gtk_text_iter_get_line (end);
if (line2 == _gtk_text_btree_line_count (tree))
{
GtkTextTag** tags;
int array_size;
GtkTextIter orig_end;
orig_end = *end;
gtk_text_iter_backward_char (end);
--line2;
if (gtk_text_iter_get_line_offset (start) == 0 &&
line1 != 0)
{
gtk_text_iter_backward_char (start);
--line1;
}
tags = _gtk_text_btree_get_tags (end,
&array_size);
if (tags != NULL)
{
int i;
i = 0;
while (i < array_size)
{
_gtk_text_btree_tag (end, &orig_end, tags[i], FALSE);
++i;
}
g_free (tags);
}
}
}
/* Broadcast the need for redisplay before we break the iterators */
_gtk_text_btree_invalidate_region (tree, start, end);
@ -877,15 +819,21 @@ _gtk_text_btree_delete (GtkTextIter *start,
if (deleted_width > 0 || deleted_height > 0)
{
ld = _gtk_text_line_get_data (start_line, view->view_id);
/* FIXME: ld is _NOT_ necessarily non-null here, but there is currently
* no way to add ld without also validating the node, which would
* be improper at this point.
*/
/* This assertion does actually fail sometimes, must
fix before stable release -hp */
g_assert (ld);
if (ld == NULL)
{
/* This means that start_line has never been validated.
* We don't really want to do the validation here but
* we do need to store our temporary sizes. So we
* create the line data and assume a line w/h of 0.
*/
ld = _gtk_text_line_data_new (view->layout, line);
_gtk_text_line_add_data (line, ld);
ld->width = 0;
ld->height = 0;
ld->valid = FALSE;
}
ld->width = MAX (deleted_width, ld->width);
ld->height += deleted_height;
ld->valid = FALSE;
@ -3377,9 +3325,27 @@ _gtk_text_line_previous (GtkTextLine *line)
return NULL;
}
GtkTextLineData*
_gtk_text_line_data_new (GtkTextLayout *layout,
GtkTextLine *line)
{
GtkTextLineData *line_data;
line_data = g_new (GtkTextLineData, 1);
line_data->view_id = layout;
line_data->next = NULL;
line_data->width = 0;
line_data->height = 0;
line_data->valid = FALSE;
return line_data;
}
void
_gtk_text_line_add_data (GtkTextLine *line,
GtkTextLineData *data)
GtkTextLineData *data)
{
g_return_if_fail (line != NULL);
g_return_if_fail (data != NULL);

View File

@ -275,6 +275,8 @@ GtkTextLine * _gtk_text_line_previous_could_contain_tag (GtkTextLine
GtkTextBTree *tree,
GtkTextTag *tag);
GtkTextLineData *_gtk_text_line_data_new (GtkTextLayout *layout,
GtkTextLine *line);
/* Debug */
void _gtk_text_btree_check (GtkTextBTree *tree);

View File

@ -86,9 +86,6 @@
#include <stdlib.h>
#include <string.h>
static GtkTextLineData *gtk_text_line_data_new (GtkTextLayout *layout,
GtkTextLine *line);
static GtkTextLineData *gtk_text_layout_real_wrap (GtkTextLayout *layout,
GtkTextLine *line,
/* may be NULL */
@ -925,7 +922,7 @@ gtk_text_layout_real_wrap (GtkTextLayout *layout,
if (line_data == NULL)
{
line_data = gtk_text_line_data_new (layout, line);
line_data = _gtk_text_line_data_new (layout, line);
_gtk_text_line_add_data (line, line_data);
}
@ -2036,24 +2033,6 @@ line_display_index_to_iter (GtkTextLayout *layout,
gtk_text_iter_forward_chars (iter, trailing);
}
/* FIXME: This really doesn't belong in this file ... */
static GtkTextLineData*
gtk_text_line_data_new (GtkTextLayout *layout,
GtkTextLine *line)
{
GtkTextLineData *line_data;
line_data = g_new (GtkTextLineData, 1);
line_data->view_id = layout;
line_data->next = NULL;
line_data->width = 0;
line_data->height = 0;
line_data->valid = FALSE;
return line_data;
}
static void
get_line_at_y (GtkTextLayout *layout,
gint y,