Newsgroups: comp.windows.x
Path: cantaloupe.srv.cs.cmu.edu!rochester!galileo.cc.rochester.edu!ub!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!world!oj
From: oj@world.std.com (Oliver Jones)
Subject: Re: XQueryTree, XGrabServer, and robustness
Message-ID: <C78I96.23A@world.std.com>
Organization: Shawsheen Software
References: <1993May18.150655.23645@viewlogic.com>
Date: Tue, 18 May 1993 18:05:28 GMT
Lines: 24

In article <1993May18.150655.23645@viewlogic.com> josh@viewlogic.com (Josh Marantz) writes:
>I have an application that wants to walk the server window hierarchy,
>looking for a window with a specific property. 

>I think what happens is that XQueryTree gives me an array of n
>children, but by the time I get to the nth child window, it has been
>destroyed.  Then I get a BadWindow error, and my application exits.
>
>How can I make this robust?  I've thought of the following:
 ...
>2.      Set up an X error handler that longjmps back to where I
>        made the offending call.  Is this safe?  Do I have to
>        longjmp, or can I just return?

BadWindow is an X protocol error.  If you write a custom error handler
which does not do "exit(1);" the error handler will return and let
your program carry on.  So, using a XSetErrorHandler is the way to
go, but never mind the longjmp.


>3.      Register for DestroyNotify on all the windows returned from
>        XQueryTree.  ...

Too hard....
