[gtk+] Be robust against unrealized windows in GtkWindowAccessible



commit bec6b260b4139d955367fa4a869c7a2cd69bf6e5
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 22 19:42:41 2012 -0400

    Be robust against unrealized windows in GtkWindowAccessible
    
    Based on a patch by Albert Astals Cid,
    https://bugzilla.gnome.org/show_bug.cgi?id=686152

 gtk/a11y/gtkwindowaccessible.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index 4b88fb5..fbc854a 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -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;



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