[gnome-control-center] Don't assume that get_preferred_* arguments can't be NULL



commit e3367c92f0c43199a229d6285d8afa212aec515e
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Nov 20 13:30:52 2010 -0500

    Don't assume that get_preferred_* arguments can't be NULL
    
    Fixes a crash introduced by f5f5aac5c065e5be0d5c080ffa1c075423c4cef7

 libgnome-control-center/cc-panel.c |   12 ++++++++++--
 panels/datetime/cc-timezone-map.c  |   17 +++++++++++++++--
 panels/display/scrollarea.c        |   14 ++++++++++++--
 panels/sound/gvc-level-bar.c       |   14 ++++++++++++--
 4 files changed, 49 insertions(+), 8 deletions(-)
---
diff --git a/libgnome-control-center/cc-panel.c b/libgnome-control-center/cc-panel.c
index 9cb5da5..0ed5627 100644
--- a/libgnome-control-center/cc-panel.c
+++ b/libgnome-control-center/cc-panel.c
@@ -131,7 +131,11 @@ cc_panel_get_preferred_width (GtkWidget *widget,
   GtkBin *bin = GTK_BIN (widget);
   GtkWidget *child;
 
-  *minimum = *natural = 0;
+  if (minimum != NULL)
+    *minimum = 0;
+
+  if (natural != NULL)
+    *natural = 0;
 
   if ((child = gtk_bin_get_child (bin)))
     gtk_widget_get_preferred_width (child, minimum, natural);
@@ -145,7 +149,11 @@ cc_panel_get_preferred_height (GtkWidget *widget,
   GtkBin *bin = GTK_BIN (widget);
   GtkWidget *child;
 
-  *minimum = *natural = 0;
+  if (minimum != NULL)
+    *minimum = 0;
+
+  if (natural != NULL)
+    *natural = 0;
 
   if ((child = gtk_bin_get_child (bin)))
     gtk_widget_get_preferred_height (child, minimum, natural);
diff --git a/panels/datetime/cc-timezone-map.c b/panels/datetime/cc-timezone-map.c
index 342f7c7..1b338b0 100644
--- a/panels/datetime/cc-timezone-map.c
+++ b/panels/datetime/cc-timezone-map.c
@@ -194,9 +194,15 @@ cc_timezone_map_get_preferred_width (GtkWidget *widget,
                                      gint      *natural)
 {
   CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+  gint size;
+
+  size = gdk_pixbuf_get_width (priv->orig_background) * 0.6;
 
   /* FIXME: should natural == full pixmap size ? */
-  *minimum = *natural = gdk_pixbuf_get_width (priv->orig_background) * 0.6;
+  if (minimum != NULL)
+    *minimum = size;
+  if (natural != NULL)
+    *natural = size;
 }
 
 static void
@@ -205,10 +211,17 @@ cc_timezone_map_get_preferred_height (GtkWidget *widget,
                                       gint      *natural)
 {
   CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+  gint size;
 
   /* FIXME: should natural == full pixmap size ? */
-  *minimum = *natural = gdk_pixbuf_get_height (priv->orig_background) * 0.6;
+  size = gdk_pixbuf_get_height (priv->orig_background) * 0.6;
+
+  if (minimum != NULL)
+    *minimum = size;
+  if (natural != NULL)
+    *natural = size;
 }
+
 static void
 cc_timezone_map_size_allocate (GtkWidget     *widget,
                                GtkAllocation *allocation)
diff --git a/panels/display/scrollarea.c b/panels/display/scrollarea.c
index 5123511..5cf807b 100644
--- a/panels/display/scrollarea.c
+++ b/panels/display/scrollarea.c
@@ -955,7 +955,12 @@ foo_scroll_area_get_preferred_width (GtkWidget *widget,
 {
     FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
 
-    *minimum = *natural = scroll_area->priv->min_width;
+    if (minimum != NULL) {
+        *minimum = scroll_area->priv->min_width;
+    }
+    if (natural != NULL) {
+        *natural = scroll_area->priv->min_width;
+    }
 }
 
 static void
@@ -965,7 +970,12 @@ foo_scroll_area_get_preferred_height (GtkWidget *widget,
 {
     FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
 
-    *minimum = *natural = scroll_area->priv->min_height;
+    if (minimum != NULL) {
+        *minimum = scroll_area->priv->min_height;
+    }
+    if (natural != NULL) {
+        *natural = scroll_area->priv->min_height;
+    }
 }
 
 static void
diff --git a/panels/sound/gvc-level-bar.c b/panels/sound/gvc-level-bar.c
index 8ffb43a..6cd421a 100644
--- a/panels/sound/gvc-level-bar.c
+++ b/panels/sound/gvc-level-bar.c
@@ -463,7 +463,12 @@ gvc_level_bar_get_preferred_width (GtkWidget *widget,
 
         gvc_level_bar_size_request (widget, &requisition);
 
-        *minimum = *natural = requisition.width;
+        if (minimum != NULL) {
+                *minimum = requisition.width;
+        }
+        if (natural != NULL) {
+                *natural = requisition.width;
+        }
 }
 
 static void
@@ -475,7 +480,12 @@ gvc_level_bar_get_preferred_height (GtkWidget *widget,
 
         gvc_level_bar_size_request (widget, &requisition);
 
-        *minimum = *natural = requisition.height;
+        if (minimum != NULL) {
+                *minimum = requisition.height;
+        }
+        if (natural != NULL) {
+                *natural = requisition.height;
+        }
 }
 
 static void



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