[vte/vte-next: 185/223] Make size_allocate safe for NULL buffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 185/223] Make size_allocate safe for NULL buffer
- Date: Wed, 22 Jun 2011 21:04:08 +0000 (UTC)
commit 6da428077c3cd55eb4e7aa8f4f5d0c27e9ede65d
Author: Christian Persch <chpe gnome org>
Date: Mon Jun 13 21:17:57 2011 +0200
Make size_allocate safe for NULL buffer
src/vte.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index f2c9a56..0016a80 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -8024,7 +8024,7 @@ vte_terminal_get_preferred_height(GtkWidget *widget,
static void
vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
- VteTerminal *terminal;
+ VteTerminal *terminal = VTE_TERMINAL(widget);
VteBuffer *buffer;
glong width, height;
GtkAllocation current_allocation;
@@ -8033,9 +8033,6 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
_vte_debug_print(VTE_DEBUG_LIFECYCLE,
"vte_terminal_size_allocate()\n");
- terminal = VTE_TERMINAL(widget);
- buffer = terminal->term_pvt->buffer;
-
width = (allocation->width - (terminal->pvt->padding.left + terminal->pvt->padding.right)) /
terminal->pvt->char_width;
height = (allocation->height - (terminal->pvt->padding.top + terminal->pvt->padding.bottom)) /
@@ -8058,6 +8055,10 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
/* Set our allocation to match the structure. */
gtk_widget_set_allocation (widget, allocation);
+ buffer = terminal->term_pvt->buffer;
+ if (buffer == NULL)
+ goto done_buffer;
+
if (width != terminal->pvt->column_count
|| height != terminal->pvt->row_count
|| update_scrollback)
@@ -8072,15 +8073,14 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
if (screen->scrolling_restricted) {
screen->scrolling_region.start =
MIN(screen->scrolling_region.start,
- terminal->pvt->row_count - 1);
+ buffer->pvt->row_count - 1);
screen->scrolling_region.end =
MIN(screen->scrolling_region.end,
- terminal->pvt->row_count - 1);
+ buffer->pvt->row_count - 1);
}
/* Ensure scrollback buffers cover the screen. */
- vte_buffer_set_scrollback_lines(terminal->term_pvt->buffer,
- terminal->pvt->scrollback_lines);
+ vte_buffer_set_scrollback_lines(buffer, buffer->pvt->scrollback_lines);
/* Ensure the cursor is valid */
screen->cursor_current.row = CLAMP (screen->cursor_current.row,
_vte_ring_delta (screen->row_data),
@@ -8090,6 +8090,8 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
_vte_terminal_queue_contents_changed(terminal);
}
+ done_buffer:
+
/* Resize the GDK window. */
if (gtk_widget_get_realized (widget)) {
gdk_window_move_resize (gtk_widget_get_window (widget),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]