[comp.windows.x] Re^2: How can I check for a valid Window id?

jcb@frisbee.Sun.COM (Jim Becker) (11/16/89)

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) writes:

->    If I do have to install an error handler how can I re-install the
->    previous error handler if one had been installed (*I* cannot know about
->    previous handlers that may have been installed)?

->In R4, XSetErrorHandler and XSetIOErrorHandler return the old handler.

There is a little chunk of logic that seems to be missing from XLib.
If the programmer is interested in capturing an operation that will
force the error handler to be called they can install their own
handler.  However, they are unable to reset the value of a non-default
handler correctly after their operation is complete. Having a routine
that would return the current handler pointer would allow nesting to
occur properly. This would be a routine `XGetErrorHandler()', thus:

	XGetErrorHandler( &old_handler );

	XSetErrorHandler( new_handler );

	   ... whatever erroneous operations ...

	XSetErrorHandler( old_handler );


would allow correct nesting.

I realize that this is a nit, but it has bitten at least myself in the
past. Yet another item to add to the wish list for X, albeit minor.

In the given case though, having a routine that determines validity and
type given an arbitrary XID would also be a useful addition to the X
wish list. 


-Jim Becker
--    
   Jim Becker / jcb%frisbee@sun.com  / Sun Microsystems    
   ...these are my opinions, and even my id disagrees..    

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (11/16/89)

    However, they are unable to reset the value of a non-default
    handler correctly after their operation is complete.

As I said, in the R4 Xlib XSetErrorHandler will return the old handler:

	oldhandler = XSetErrorHandler(myhandler);
	<do your own thing>
	XSetErrorHandler(oldhandler);