From c3e65e9d43a62e894fb28091809c30d7bcc066d1 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 12 Dec 2008 20:34:41 +0900 Subject: [PATCH] Fix some runtime warnings --- lib/gtksheet/gtksheet.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index 088a1aba..955e77e2 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -226,12 +226,20 @@ static gboolean on_column_boundary (const GtkSheet *sheet, gint x, gint *column) { gint col; + gint pixel; x += sheet->hadjustment->value; + if ( x < 0) + return FALSE; + col = column_from_xpixel (sheet, x); - if ( column_from_xpixel (sheet, x - DRAG_WIDTH / 2) < col ) + pixel = x - DRAG_WIDTH / 2; + if (pixel < 0) + pixel = 0; + + if ( column_from_xpixel (sheet, pixel) < col ) { *column = col - 1; return TRUE; @@ -250,12 +258,20 @@ static gboolean on_row_boundary (const GtkSheet *sheet, gint y, gint *row) { gint r; + gint pixel; y += sheet->vadjustment->value; + if ( y < 0) + return FALSE; + r = row_from_ypixel (sheet, y); - if ( row_from_ypixel (sheet, y - DRAG_WIDTH / 2) < r ) + pixel = y - DRAG_WIDTH / 2; + if (pixel < 0) + pixel = 0; + + if ( row_from_ypixel (sheet, pixel) < r ) { *row = r - 1; return TRUE; @@ -5095,6 +5111,9 @@ set_column_width (GtkSheet *sheet, if (column < 0 || column >= psppire_axis_unit_count (sheet->haxis)) return; + if ( width <= 0) + return; + psppire_axis_resize (sheet->haxis, column, width); if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) @@ -5117,6 +5136,9 @@ set_row_height (GtkSheet *sheet, if (row < 0 || row >= psppire_axis_unit_count (sheet->vaxis)) return; + if (height <= 0) + return; + psppire_axis_resize (sheet->vaxis, row, height); if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) ) -- 2.30.2