]> Pileus Git - ~andy/gtk/commitdiff
Make gdk_window_foreign_new fail gracefully
authorElliot Lee <sopwith@src.gnome.org>
Thu, 16 Jul 1998 19:41:12 +0000 (19:41 +0000)
committerElliot Lee <sopwith@src.gnome.org>
Thu, 16 Jul 1998 19:41:12 +0000 (19:41 +0000)
gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c

index 5b695b270082f80553dff9c123a793f97268a688..cb04d61a0fe84cdb0df651a7ddfc652411afa57f 100644 (file)
@@ -465,17 +465,21 @@ gdk_window_foreign_new (guint32 anid)
   GdkWindowPrivate *parent_private;
   XWindowAttributes attrs;
   Window root, parent;
-  Window *children;
+  Window *children = NULL;
   guint nchildren;
 
+  if(!XGetWindowAttributes (gdk_display, anid, &attrs)) {
+    g_warning("XGetWindowAttributes failed on window ID %d\n", anid);
+    return NULL;
+  }
+
   private = g_new (GdkWindowPrivate, 1);
   window = (GdkWindow*) private;
 
-  XGetWindowAttributes (gdk_display, anid, &attrs);
-
   /* FIXME: This is pretty expensive. Maybe the caller should supply
    *        the parent */
   XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
+
   if (children)
     XFree (children);
   private->parent = gdk_xid_table_lookup (parent);
index 5b695b270082f80553dff9c123a793f97268a688..cb04d61a0fe84cdb0df651a7ddfc652411afa57f 100644 (file)
@@ -465,17 +465,21 @@ gdk_window_foreign_new (guint32 anid)
   GdkWindowPrivate *parent_private;
   XWindowAttributes attrs;
   Window root, parent;
-  Window *children;
+  Window *children = NULL;
   guint nchildren;
 
+  if(!XGetWindowAttributes (gdk_display, anid, &attrs)) {
+    g_warning("XGetWindowAttributes failed on window ID %d\n", anid);
+    return NULL;
+  }
+
   private = g_new (GdkWindowPrivate, 1);
   window = (GdkWindow*) private;
 
-  XGetWindowAttributes (gdk_display, anid, &attrs);
-
   /* FIXME: This is pretty expensive. Maybe the caller should supply
    *        the parent */
   XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
+
   if (children)
     XFree (children);
   private->parent = gdk_xid_table_lookup (parent);