From 5e3acecc12dc9b7671ea56150a66e2ae41a65a6e Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Thu, 16 Jul 1998 19:41:12 +0000 Subject: [PATCH] Make gdk_window_foreign_new fail gracefully --- gdk/gdkwindow.c | 10 +++++++--- gdk/x11/gdkwindow-x11.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 5b695b2700..cb04d61a0f 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -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); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 5b695b2700..cb04d61a0f 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -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);