[gnome-color-manager] trivial: don't hang the CPU if the gamma widget has no size



commit 77eda85a5629043c90b0ced323f4514b66b4c1e6
Author: Richard Hughes <richard hughsie com>
Date:   Mon Dec 21 15:48:43 2009 +0000

    trivial: don't hang the CPU if the gamma widget has no size

 src/gcm-gamma-widget.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/src/gcm-gamma-widget.c b/src/gcm-gamma-widget.c
index 62220cd..6bee986 100644
--- a/src/gcm-gamma-widget.c
+++ b/src/gcm-gamma-widget.c
@@ -42,8 +42,6 @@ struct GcmGammaWidgetPrivate
 	guint			 chart_width;
 	guint			 chart_height;
 	cairo_t			*cr;
-	guint			 x_offset;
-	guint			 y_offset;
 };
 
 static gboolean gcm_gamma_widget_expose (GtkWidget *gamma, GdkEventExpose *event);
@@ -291,21 +289,19 @@ gcm_gamma_widget_draw (GtkWidget *gamma_widget, cairo_t *cr)
 	g_return_if_fail (gama != NULL);
 	g_return_if_fail (GCM_IS_GAMMA_WIDGET (gama));
 
-	cairo_save (cr);
-
 	/* make size adjustment */
 	gtk_widget_get_allocation (gamma_widget, &allocation);
+	if (allocation.height <= 5 || allocation.width <= 5)
+		return;
+
+	/* save */
 	gama->priv->chart_height = ((guint) (allocation.height / 2) * 2) - 1;
 	gama->priv->chart_width = allocation.width;
-	gama->priv->x_offset = 1;
-	gama->priv->y_offset = 1;
 
 	/* gamma background */
 	gcm_gamma_widget_draw_bounding_box (cr, 0, 0, gama->priv->chart_width, gama->priv->chart_height);
 	gcm_gamma_widget_draw_lines (gama, cr);
 	gcm_gamma_widget_draw_box (gama, cr);
-
-	cairo_restore (cr);
 }
 
 /**



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