Handle _gtk_text_line_get_data() returning NULL in all cases. (Coverity)

2006-04-12  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtktextlayout.c (gtk_text_layout_validate_yrange):
	Handle _gtk_text_line_get_data() returning NULL in all
	cases.  (Coverity)
This commit is contained in:
Matthias Clasen 2006-04-12 16:28:54 +00:00 committed by Matthias Clasen
parent 5977f7f027
commit 374c855496
3 changed files with 23 additions and 8 deletions

View File

@ -1,5 +1,9 @@
2006-04-12 Matthias Clasen <mclasen@redhat.com> 2006-04-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_validate_yrange):
Handle _gtk_text_line_get_data() returning NULL in all
cases. (Coverity)
* gtk/gtkuimanager.c: Make find_menu_position and * gtk/gtkuimanager.c: Make find_menu_position and
find_toolbar_position void. (#338100) find_toolbar_position void. (#338100)

View File

@ -1,5 +1,9 @@
2006-04-12 Matthias Clasen <mclasen@redhat.com> 2006-04-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_validate_yrange):
Handle _gtk_text_line_get_data() returning NULL in all
cases. (Coverity)
* gtk/gtkuimanager.c: Make find_menu_position and * gtk/gtkuimanager.c: Make find_menu_position and
find_toolbar_position void. (#338100) find_toolbar_position void. (#338100)

View File

@ -943,16 +943,20 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout); GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout);
if (!line_data || !line_data->valid) if (!line_data || !line_data->valid)
{ {
gint old_height = line_data ? line_data->height : 0; gint old_height, new_height;
old_height = line_data ? line_data->height : 0;
_gtk_text_btree_validate_line (_gtk_text_buffer_get_btree (layout->buffer), _gtk_text_btree_validate_line (_gtk_text_buffer_get_btree (layout->buffer),
line, layout); line, layout);
line_data = _gtk_text_line_get_data (line, layout); line_data = _gtk_text_line_get_data (line, layout);
delta_height += line_data->height - old_height; new_height = line_data ? line_data->height : 0;
delta_height += new_height - old_height;
first_line = line; first_line = line;
first_line_y = -seen - line_data->height; first_line_y = -seen - new_height;
if (!last_line) if (!last_line)
{ {
last_line = line; last_line = line;
@ -960,7 +964,7 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
} }
} }
seen += line_data->height; seen += line_data ? line_data->height : 0;
line = _gtk_text_line_previous (line); line = _gtk_text_line_previous (line);
} }
@ -972,13 +976,16 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout); GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout);
if (!line_data || !line_data->valid) if (!line_data || !line_data->valid)
{ {
gint old_height = line_data ? line_data->height : 0; gint old_height, new_height;
old_height = line_data ? line_data->height : 0;
_gtk_text_btree_validate_line (_gtk_text_buffer_get_btree (layout->buffer), _gtk_text_btree_validate_line (_gtk_text_buffer_get_btree (layout->buffer),
line, layout); line, layout);
line_data = _gtk_text_line_get_data (line, layout); line_data = _gtk_text_line_get_data (line, layout);
new_height = line_data ? line_data->height : 0;
delta_height += line_data->height - old_height; delta_height += new_height - old_height;
if (!first_line) if (!first_line)
{ {
@ -986,10 +993,10 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
first_line_y = seen; first_line_y = seen;
} }
last_line = line; last_line = line;
last_line_y = seen + line_data->height; last_line_y = seen + new_height;
} }
seen += line_data->height; seen += line_data ? line_data->height : 0;
line = _gtk_text_line_next_excluding_last (line); line = _gtk_text_line_next_excluding_last (line);
} }