[gnome-control-center] [shell] Don't use window before it is realized



commit 7d50b3787c467873ef74e772339418682e7927f3
Author: William Jon McCann <jmccann redhat com>
Date:   Mon Nov 1 16:58:40 2010 -0400

    [shell] Don't use window before it is realized

 shell/gnome-control-center.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 75ad2c1..512c740 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -894,18 +894,23 @@ on_window_size_allocate (GtkWidget          *widget,
 
   if (gtk_notebook_get_current_page (GTK_NOTEBOOK (self->priv->notebook)) == OVERVIEW_PAGE)
     {
-      int          monitor;
-      GdkScreen   *screen;
-      GdkRectangle rect;
-      screen = gtk_widget_get_screen (widget);
-      monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
-      gdk_screen_get_monitor_geometry (screen, monitor, &rect);
-
       gtk_widget_get_preferred_height_for_width (GTK_WIDGET (self->priv->main_vbox),
                                                  FIXED_WIDTH,
                                                  NULL,
                                                  &height);
-      height = MIN (height + 10, rect.height);
+      if (gtk_widget_get_realized (widget))
+        {
+          int          monitor;
+          GdkScreen   *screen;
+          GdkRectangle rect;
+          GdkWindow   *window;
+
+          window = gtk_widget_get_window (widget);
+          screen = gtk_widget_get_screen (widget);
+          monitor = gdk_screen_get_monitor_at_window (screen, window);
+          gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+          height = MIN (height + 10, rect.height);
+        }
     }
   else
     {



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