]> Pileus Git - ~andy/gtk/commitdiff
Be robust against unrealized windows in GtkWindowAccessible
authorMatthias Clasen <mclasen@redhat.com>
Mon, 22 Oct 2012 23:42:41 +0000 (19:42 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 22 Oct 2012 23:42:41 +0000 (19:42 -0400)
Based on a patch by Albert Astals Cid,
https://bugzilla.gnome.org/show_bug.cgi?id=686152

gtk/a11y/gtkwindowaccessible.c

index 4b88fb54d95ee38b1aff7d4447085e54bede2e60..fbc854a5f111e776940162dd6d99d5f78f866df7 100644 (file)
@@ -262,7 +262,7 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible)
     atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
 
   gdk_window = gtk_widget_get_window (widget);
-  if (window)
+  if (gdk_window)
     {
       state = gdk_window_get_state (gdk_window);
       if (state & GDK_WINDOW_STATE_ICONIFIED)
@@ -307,6 +307,7 @@ gtk_window_accessible_get_extents (AtkComponent  *component,
                                    AtkCoordType   coord_type)
 {
   GtkWidget *widget;
+  GdkWindow *window;
   GdkRectangle rect;
   gint x_toplevel, y_toplevel;
 
@@ -323,7 +324,11 @@ gtk_window_accessible_get_extents (AtkComponent  *component,
       return;
     }
 
-  gdk_window_get_frame_extents (gtk_widget_get_window (widget), &rect);
+  window = gtk_widget_get_window (widget);
+  if (window == NULL)
+    return;
+
+  gdk_window_get_frame_extents (window, &rect);
 
   *width = rect.width;
   *height = rect.height;
@@ -338,8 +343,7 @@ gtk_window_accessible_get_extents (AtkComponent  *component,
   *y = rect.y;
   if (coord_type == ATK_XY_WINDOW)
     {
-      gdk_window_get_origin (gtk_widget_get_window (widget),
-                             &x_toplevel, &y_toplevel);
+      gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
       *x -= x_toplevel;
       *y -= y_toplevel;
     }
@@ -351,6 +355,7 @@ gtk_window_accessible_get_size (AtkComponent *component,
                                 gint         *height)
 {
   GtkWidget *widget;
+  GdkWindow *window;
   GdkRectangle rect;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
@@ -366,7 +371,11 @@ gtk_window_accessible_get_size (AtkComponent *component,
       return;
     }
 
-  gdk_window_get_frame_extents (gtk_widget_get_window (widget), &rect);
+  window = gtk_widget_get_window (widget);
+  if (window == NULL)
+    return;
+
+  gdk_window_get_frame_extents (window, &rect);
 
   *width = rect.width;
   *height = rect.height;