[gthumb] ignore allocation when the size is zero to make the code more robust



commit 8b913ccc7392bd41b08adb355ced9e10357ef3fb
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri May 14 10:48:29 2010 +0200

    ignore allocation when the size is zero to make the code more robust

 gthumb/gth-image-dragger.c |    6 +++---
 gthumb/gth-image-viewer.c  |    9 +++++++--
 gthumb/gth-nav-window.c    |    4 ++--
 3 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gthumb/gth-image-dragger.c b/gthumb/gth-image-dragger.c
index 756eb31..635b124 100644
--- a/gthumb/gth-image-dragger.c
+++ b/gthumb/gth-image-dragger.c
@@ -97,8 +97,8 @@ gth_image_dragger_unrealize (GthImageViewerTool *base)
 
 
 static void
-gth_image_dragger_size_allocate (GthImageViewerTool  *base,
-				 GtkAllocation       *allocation)
+gth_image_dragger_size_allocate (GthImageViewerTool *base,
+				 GtkAllocation      *allocation)
 {
 	GthImageDragger *self;
 	GthImageViewer  *viewer;
@@ -106,7 +106,7 @@ gth_image_dragger_size_allocate (GthImageViewerTool  *base,
 	self = (GthImageDragger *) base;
 	viewer = (GthImageViewer *) self->priv->viewer;
 
-	self->priv->draggable = (viewer->hadj->upper > viewer->hadj->page_size) || (viewer->vadj->upper > viewer->vadj->page_size);
+	self->priv->draggable = (viewer->hadj->page_size > 0) && (viewer->vadj->page_size > 0) && ((viewer->hadj->upper > viewer->hadj->page_size) || (viewer->vadj->upper > viewer->vadj->page_size));
 	if (GTK_WIDGET_REALIZED (viewer))
 		_gth_image_dragger_update_cursor (self);
 }
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index aacb18a..e69c126 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -495,6 +495,9 @@ gth_image_viewer_size_allocate (GtkWidget       *widget,
 	gdk_width = allocation->width - viewer->priv->frame_border2;
 	gdk_height = allocation->height - viewer->priv->frame_border2;
 
+	if ((gdk_width < 0) || (gdk_height < 0))
+		return;
+
 	current_pixbuf = gth_image_viewer_get_current_pixbuf (viewer);
 
 	/* If a fit type is active update the zoom level. */
@@ -601,8 +604,10 @@ gth_image_viewer_size_allocate (GtkWidget       *widget,
 
 	if (GTK_WIDGET_REALIZED (widget))
 		gdk_window_move_resize (widget->window,
-					allocation->x, allocation->y,
-					allocation->width, allocation->height);
+					allocation->x,
+					allocation->y,
+					allocation->width,
+					allocation->height);
 
 	gth_image_viewer_tool_size_allocate (viewer->priv->tool, allocation);
 
diff --git a/gthumb/gth-nav-window.c b/gthumb/gth-nav-window.c
index dde50c4..05f7eec 100644
--- a/gthumb/gth-nav-window.c
+++ b/gthumb/gth-nav-window.c
@@ -111,8 +111,8 @@ size_changed_cb (GtkWidget    *widget,
 	g_return_val_if_fail (hadj != NULL, FALSE);
 	g_return_val_if_fail (vadj != NULL, FALSE);
 
-	hide_vscr = (vadj->upper <= vadj->page_size);
-	hide_hscr = (hadj->upper <= hadj->page_size);
+	hide_vscr = (vadj->page_size == 0) || (vadj->upper <= vadj->page_size);
+	hide_hscr = (hadj->page_size == 0) || (hadj->upper <= hadj->page_size);
 
 	if (! nav_window->priv->scrollbars_visible || (hide_vscr && hide_hscr)) {
 		gtk_widget_hide (nav_window->priv->viewer_vscr);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]