just go ahead and flush all the first validate stuff if it hasn't been

2002-02-13  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
	all the first validate stuff if it hasn't been done, presumably
	someone called process_updates at a weird time.

	* tests/testtext.c (do_apply_colors): terminate on >= end, not >
	end, avoids infinite loop when end is at the end of the buffer.

	* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
	line data, we were adding it to the wrong line ("line" instead of
	"start_line")
This commit is contained in:
Havoc Pennington 2002-02-13 23:44:03 +00:00 committed by Havoc Pennington
parent 3a4a6edb79
commit a760ad804e
13 changed files with 205 additions and 48 deletions

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -1,3 +1,16 @@
2002-02-13 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): just go ahead and flush
all the first validate stuff if it hasn't been done, presumably
someone called process_updates at a weird time.
* tests/testtext.c (do_apply_colors): terminate on >= end, not >
end, avoids infinite loop when end is at the end of the buffer.
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when creating a
line data, we were adding it to the wrong line ("line" instead of
"start_line")
2002-02-13 Joe Shaw <joe@ximian.com> 2002-02-13 Joe Shaw <joe@ximian.com>
* gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the * gtk/gtktreeitem.c (gtk_tree_item_expose): Don't chain up to the

View File

@ -575,6 +575,7 @@ _gtk_text_btree_delete (GtkTextIter *start,
_gtk_text_btree_check (tree); _gtk_text_btree_check (tree);
/* Broadcast the need for redisplay before we break the iterators */ /* Broadcast the need for redisplay before we break the iterators */
DV (g_print ("invalidating due to deleting some text (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (tree, start, end); _gtk_text_btree_invalidate_region (tree, start, end);
/* Save the byte offset so we can reset the iterators */ /* Save the byte offset so we can reset the iterators */
@ -826,8 +827,8 @@ _gtk_text_btree_delete (GtkTextIter *start,
* we do need to store our temporary sizes. So we * we do need to store our temporary sizes. So we
* create the line data and assume a line w/h of 0. * create the line data and assume a line w/h of 0.
*/ */
ld = _gtk_text_line_data_new (view->layout, line); ld = _gtk_text_line_data_new (view->layout, start_line);
_gtk_text_line_add_data (line, ld); _gtk_text_line_add_data (start_line, ld);
ld->width = 0; ld->width = 0;
ld->height = 0; ld->height = 0;
ld->valid = FALSE; ld->valid = FALSE;
@ -1033,6 +1034,7 @@ _gtk_text_btree_insert (GtkTextIter *iter,
above. FIXME */ above. FIXME */
gtk_text_iter_forward_chars (&end, char_count_delta); gtk_text_iter_forward_chars (&end, char_count_delta);
DV (g_print ("invalidating due to inserting some text (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (tree, _gtk_text_btree_invalidate_region (tree,
&start, &end); &start, &end);
@ -1081,6 +1083,7 @@ insert_pixbuf_or_widget_segment (GtkTextIter *iter,
*iter = start; *iter = start;
gtk_text_iter_forward_char (iter); /* skip forward past the segment */ gtk_text_iter_forward_char (iter); /* skip forward past the segment */
DV (g_print ("invalidating due to inserting pixbuf/widget (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (tree, &start, iter); _gtk_text_btree_invalidate_region (tree, &start, iter);
} }
@ -1526,6 +1529,7 @@ queue_tag_redisplay (GtkTextBTree *tree,
{ {
if (_gtk_text_tag_affects_size (tag)) if (_gtk_text_tag_affects_size (tag))
{ {
DV (g_print ("invalidating due to size-affecting tag (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (tree, start, end); _gtk_text_btree_invalidate_region (tree, start, end);
} }
else if (_gtk_text_tag_affects_nonsize_appearance (tag)) else if (_gtk_text_tag_affects_nonsize_appearance (tag))
@ -2448,6 +2452,7 @@ redisplay_mark (GtkTextLineSegment *mark)
end = iter; end = iter;
gtk_text_iter_forward_char (&end); gtk_text_iter_forward_char (&end);
DV (g_print ("invalidating due to moving visible mark (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (mark->body.mark.tree, _gtk_text_btree_invalidate_region (mark->body.mark.tree,
&iter, &end); &iter, &end);
} }
@ -5411,6 +5416,7 @@ tag_changed_cb (GtkTextTagTable *table,
{ {
/* Must be a last toggle if there was a first one. */ /* Must be a last toggle if there was a first one. */
_gtk_text_btree_get_iter_at_last_toggle (tree, &end, tag); _gtk_text_btree_get_iter_at_last_toggle (tree, &end, tag);
DV (g_print ("invalidating due to tag change (%s)\n", G_STRLOC));
_gtk_text_btree_invalidate_region (tree, _gtk_text_btree_invalidate_region (tree,
&start, &end); &start, &end);

View File

@ -1,6 +1,16 @@
#ifndef GTK_TEXT_BTREE_H #ifndef GTK_TEXT_BTREE_H
#define GTK_TEXT_BTREE_H #define GTK_TEXT_BTREE_H
#if 0
#define DEBUG_VALIDATION_AND_SCROLLING
#endif
#ifdef DEBUG_VALIDATION_AND_SCROLLING
#define DV(x) (x)
#else
#define DV(x)
#endif
#include <gtk/gtktextbuffer.h> #include <gtk/gtktextbuffer.h>
#include <gtk/gtktexttag.h> #include <gtk/gtktexttag.h>
#include <gtk/gtktextmark.h> #include <gtk/gtktextmark.h>

View File

@ -850,6 +850,15 @@ gtk_text_buffer_real_insert_range (GtkTextBuffer *buffer,
range_start = start; range_start = start;
range_end = start; range_end = start;
/* FIXME if you insert a range into itself, this can loop infinitely because
* the region being copied keeps growing as we insert. The fix is probably to create a
* copy of what's being inserted, or to save two regions, the region before
* the insertion point and the region after.
*
* http://bugzilla.gnome.org/show_bug.cgi?id=71412
*/
while (TRUE) while (TRUE)
{ {
gint start_offset; gint start_offset;

View File

@ -293,6 +293,7 @@ gtk_text_layout_default_style_changed (GtkTextLayout *layout)
{ {
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout)); g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
DV (g_print ("invalidating all due to default style change (%s)\n", G_STRLOC));
gtk_text_layout_invalidate_all (layout); gtk_text_layout_invalidate_all (layout);
} }
@ -335,6 +336,7 @@ gtk_text_layout_set_contexts (GtkTextLayout *layout,
layout->rtl_context = rtl_context; layout->rtl_context = rtl_context;
g_object_ref (G_OBJECT (rtl_context)); g_object_ref (G_OBJECT (rtl_context));
DV (g_print ("invalidating all due to new pango contexts (%s)\n", G_STRLOC));
gtk_text_layout_invalidate_all (layout); gtk_text_layout_invalidate_all (layout);
} }
@ -391,6 +393,7 @@ gtk_text_layout_set_screen_width (GtkTextLayout *layout, gint width)
layout->screen_width = width; layout->screen_width = width;
DV (g_print ("invalidating all due to new screen width (%s)\n", G_STRLOC));
gtk_text_layout_invalidate_all (layout); gtk_text_layout_invalidate_all (layout);
} }
@ -919,6 +922,7 @@ gtk_text_layout_real_wrap (GtkTextLayout *layout,
GtkTextLineDisplay *display; GtkTextLineDisplay *display;
g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), NULL); g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), NULL);
g_return_val_if_fail (line != NULL, NULL);
if (line_data == NULL) if (line_data == NULL)
{ {

View File

@ -82,9 +82,6 @@
* *
*/ */
#define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window)
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window)
#if 0 #if 0
#define DEBUG_VALIDATION_AND_SCROLLING #define DEBUG_VALIDATION_AND_SCROLLING
#endif #endif
@ -95,6 +92,9 @@
#define DV(x) #define DV(x)
#endif #endif
#define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window)
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window)
struct _GtkTextPendingScroll struct _GtkTextPendingScroll
{ {
GtkTextMark *mark; GtkTextMark *mark;
@ -315,6 +315,7 @@ static void gtk_text_view_queue_scroll (GtkTextView *text_view,
static gboolean gtk_text_view_flush_scroll (GtkTextView *text_view); static gboolean gtk_text_view_flush_scroll (GtkTextView *text_view);
static void gtk_text_view_update_adjustments (GtkTextView *text_view); static void gtk_text_view_update_adjustments (GtkTextView *text_view);
static void gtk_text_view_invalidate (GtkTextView *text_view); static void gtk_text_view_invalidate (GtkTextView *text_view);
static void gtk_text_view_flush_first_validate (GtkTextView *text_view);
static void gtk_text_view_update_im_spot_location (GtkTextView *text_view); static void gtk_text_view_update_im_spot_location (GtkTextView *text_view);
@ -1147,6 +1148,7 @@ gtk_text_view_set_buffer (GtkTextView *text_view,
if (GTK_WIDGET_VISIBLE (text_view)) if (GTK_WIDGET_VISIBLE (text_view))
gtk_widget_queue_draw (GTK_WIDGET (text_view)); gtk_widget_queue_draw (GTK_WIDGET (text_view));
DV(g_print ("Invalidating due to set_buffer\n"));
gtk_text_view_invalidate (text_view); gtk_text_view_invalidate (text_view);
} }
@ -1547,7 +1549,10 @@ gtk_text_view_flush_scroll (GtkTextView *text_view)
DV(g_print(G_STRLOC"\n")); DV(g_print(G_STRLOC"\n"));
if (text_view->pending_scroll == NULL) if (text_view->pending_scroll == NULL)
{
DV (g_print ("in flush scroll, no pending scroll\n"));
return FALSE; return FALSE;
}
scroll = text_view->pending_scroll; scroll = text_view->pending_scroll;
@ -2365,6 +2370,7 @@ gtk_text_view_remove_validate_idles (GtkTextView *text_view)
{ {
if (text_view->first_validate_idle != 0) if (text_view->first_validate_idle != 0)
{ {
DV (g_print ("Removing first validate idle: %s\n", G_STRLOC));
g_source_remove (text_view->first_validate_idle); g_source_remove (text_view->first_validate_idle);
text_view->first_validate_idle = 0; text_view->first_validate_idle = 0;
} }
@ -2938,19 +2944,11 @@ gtk_text_view_size_allocate (GtkWidget *widget,
if (yoffset_changed) if (yoffset_changed)
gtk_adjustment_value_changed (vadj); gtk_adjustment_value_changed (vadj);
if (text_view->first_validate_idle != 0)
{
/* The GTK resize loop processes all the pending exposes right /* The GTK resize loop processes all the pending exposes right
* after doing the resize stuff, so the idle sizer won't have a * after doing the resize stuff, so the idle sizer won't have a
* chance to run. So we do the work here. * chance to run. So we do the work here.
*/ */
gtk_text_view_flush_first_validate (text_view);
g_source_remove (text_view->first_validate_idle);
text_view->first_validate_idle = 0;
if (!gtk_text_view_flush_scroll (text_view))
gtk_text_view_validate_onscreen (text_view);
}
/* widget->window doesn't get auto-redrawn as the layout is computed, so has to /* widget->window doesn't get auto-redrawn as the layout is computed, so has to
* be invalidated * be invalidated
@ -3004,23 +3002,18 @@ gtk_text_view_validate_onscreen (GtkTextView *text_view)
g_assert (text_view->onscreen_validated); g_assert (text_view->onscreen_validated);
} }
static gboolean static void
first_validate_callback (gpointer data) gtk_text_view_flush_first_validate (GtkTextView *text_view)
{ {
GtkTextView *text_view = data; if (text_view->first_validate_idle == 0)
return;
GDK_THREADS_ENTER ();
/* Note that some of this code is duplicated at the end of size_allocate,
* keep in sync with that.
*/
DV(g_print(G_STRLOC"\n"));
/* Do this first, which means that if an "invalidate" /* Do this first, which means that if an "invalidate"
* occurs during any of this process, a new first_validate_callback * occurs during any of this process, a new first_validate_callback
* will be installed, and we'll start again. * will be installed, and we'll start again.
*/ */
DV (g_print ("removing first validate in %s\n", G_STRLOC));
g_source_remove (text_view->first_validate_idle);
text_view->first_validate_idle = 0; text_view->first_validate_idle = 0;
/* be sure we have up-to-date screen size set on the /* be sure we have up-to-date screen size set on the
@ -3047,8 +3040,23 @@ first_validate_callback (gpointer data)
DV(g_print(">Leaving first validate idle ("G_STRLOC")\n")); DV(g_print(">Leaving first validate idle ("G_STRLOC")\n"));
g_assert (text_view->onscreen_validated); g_assert (text_view->onscreen_validated);
} }
}
static gboolean
first_validate_callback (gpointer data)
{
GtkTextView *text_view = data;
GDK_THREADS_ENTER ();
/* Note that some of this code is duplicated at the end of size_allocate,
* keep in sync with that.
*/
DV(g_print(G_STRLOC"\n"));
gtk_text_view_flush_first_validate (text_view);
GDK_THREADS_LEAVE (); GDK_THREADS_LEAVE ();
@ -3083,9 +3091,10 @@ incremental_validate_callback (gpointer data)
static void static void
gtk_text_view_invalidate (GtkTextView *text_view) gtk_text_view_invalidate (GtkTextView *text_view)
{ {
text_view->onscreen_validated = FALSE; DV (g_print (">Invalidate, onscreen_validated = %d now FALSE ("G_STRLOC")\n",
text_view->onscreen_validated));
DV(g_print(">Invalidate, onscreen_validated = FALSE ("G_STRLOC")\n")); text_view->onscreen_validated = FALSE;
if (!text_view->first_validate_idle) if (!text_view->first_validate_idle)
{ {
@ -3110,6 +3119,7 @@ invalidated_handler (GtkTextLayout *layout,
text_view = GTK_TEXT_VIEW (data); text_view = GTK_TEXT_VIEW (data);
DV (g_print ("Invalidating due to layout invalidate signal\n"));
gtk_text_view_invalidate (text_view); gtk_text_view_invalidate (text_view);
} }
@ -3205,7 +3215,10 @@ changed_handler (GtkTextLayout *layout,
} }
if (yoffset_changed) if (yoffset_changed)
{
DV(g_print ("Changing scroll position (%s)\n", G_STRLOC));
gtk_adjustment_value_changed (get_vadjustment (text_view)); gtk_adjustment_value_changed (get_vadjustment (text_view));
}
/* FIXME be smarter about which anchored widgets we update */ /* FIXME be smarter about which anchored widgets we update */
@ -4007,6 +4020,7 @@ gtk_text_view_paint (GtkWidget *widget,
GtkTextView *text_view; GtkTextView *text_view;
GList *child_exposes; GList *child_exposes;
GList *tmp_list; GList *tmp_list;
GdkRegion *updates;
text_view = GTK_TEXT_VIEW (widget); text_view = GTK_TEXT_VIEW (widget);
@ -4014,12 +4028,29 @@ gtk_text_view_paint (GtkWidget *widget,
g_return_if_fail (text_view->xoffset >= 0); g_return_if_fail (text_view->xoffset >= 0);
g_return_if_fail (text_view->yoffset >= 0); g_return_if_fail (text_view->yoffset >= 0);
while (text_view->first_validate_idle != 0)
{
DV (g_print (G_STRLOC": first_validate_idle: %d\n", DV (g_print (G_STRLOC": first_validate_idle: %d\n",
text_view->first_validate_idle)); text_view->first_validate_idle));
gtk_text_view_flush_first_validate (text_view);
}
/* More regions could have become invalid in the above loop */
updates = gdk_window_get_update_area (text_view->text_window->bin_window);
if (updates)
{
GdkRectangle rect;
gdk_region_get_clipbox (updates, &rect);
gdk_rectangle_union (area, &rect, area);
gdk_region_destroy (updates);
}
if (!text_view->onscreen_validated) if (!text_view->onscreen_validated)
{ {
g_warning (G_STRLOC ": somehow some text lines were modified or scrolling occurred since the last validation of lines on the screen - this is a known bug, no need to report."); g_warning (G_STRLOC ": somehow some text lines were modified or scrolling occurred since the last validation of lines on the screen - may be a text widget bug.");
G_BREAKPOINT (); G_BREAKPOINT ();
} }
@ -4957,6 +4988,7 @@ move_mark_to_pointer_and_scroll (GtkTextView *text_view,
GtkTextMark *mark = GtkTextMark *mark =
gtk_text_buffer_get_mark (get_buffer (text_view), mark_name); gtk_text_buffer_get_mark (get_buffer (text_view), mark_name);
/* This may invalidate the layout */
DV(g_print (G_STRLOC": move mark\n")); DV(g_print (G_STRLOC": move mark\n"));
gtk_text_buffer_move_mark (get_buffer (text_view), gtk_text_buffer_move_mark (get_buffer (text_view),
mark, mark,
@ -4965,6 +4997,9 @@ move_mark_to_pointer_and_scroll (GtkTextView *text_view,
DV(g_print (G_STRLOC": scrolling onscreen\n")); DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view, mark); gtk_text_view_scroll_mark_onscreen (text_view, mark);
} }
DV (g_print ("first validate idle leaving %s is %d\n",
G_STRLOC, text_view->first_validate_idle));
} }
static gint static gint
@ -5865,6 +5900,8 @@ gtk_text_view_value_changed (GtkAdjustment *adj,
/* process exposes */ /* process exposes */
if (GTK_WIDGET_REALIZED (text_view)) if (GTK_WIDGET_REALIZED (text_view))
{ {
DV (g_print ("Processing updates (%s)", G_STRLOC));
if (text_view->left_window) if (text_view->left_window)
gdk_window_process_updates (text_view->left_window->bin_window, TRUE); gdk_window_process_updates (text_view->left_window->bin_window, TRUE);

View File

@ -1086,7 +1086,7 @@ do_apply_colors (gpointer callback_data,
gtk_text_iter_forward_char (&next); gtk_text_iter_forward_char (&next);
gtk_text_iter_forward_char (&next); gtk_text_iter_forward_char (&next);
if (gtk_text_iter_compare (&next, &end) > 0) if (gtk_text_iter_compare (&next, &end) >= 0)
{ {
next = end; next = end;
done = TRUE; done = TRUE;