Index: metacity/src/window-props.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window-props.c,v
retrieving revision 1.26
diff -u -p -r1.26 window-props.c
--- metacity/src/window-props.c	25 Mar 2006 22:57:22 -0000	1.26
+++ metacity/src/window-props.c	18 Apr 2006 22:13:55 -0000
@@ -1130,6 +1130,15 @@ reload_transient_for (MetaWindow    *win
   if (value->type != META_PROP_VALUE_INVALID)
     window->xtransient_for = value->v.xwindow;
 
+  /* Only set transient_for to a top-level window. See #335524 */
+  if (window->xtransient_for != None &&
+      !meta_display_lookup_x_window (window->display, window->xtransient_for))
+    {
+      window->xtransient_for = None;
+      meta_warning (_("Cannot set %s transient for 0x%lx. 0x%lx is not a top-level window.\n"), 
+          window->desc, window->xtransient_for, window->xtransient_for);
+    }
+
   window->transient_parent_is_root_window =
     window->xtransient_for == window->screen->xroot;
 
