home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!stanford.edu!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: X Error on busy cursor routine from FAQ
- Message-ID: <1992Aug28.085555.7700@thunder.mcrcim.mcgill.edu>
- Organization: McGill Research Centre for Intelligent Machines
- References: <1992Aug25.224324.7877@asd.com>
- Date: Fri, 28 Aug 92 08:55:55 GMT
- Lines: 70
-
- In article <1992Aug25.224324.7877@asd.com>, scott@asd.com (Scott Barman) writes:
-
- > I read the FAQ. I wanted a busy cursor and have input blocked, so I
- > wrote a function based on what I found in FAQ #122. [...] However,
- > when I run the code I get the following error:
-
- > X Error of failed request: BadWindow (invalid Window parameter)
- > Major opcode of failed request: 1 (X_CreateWindow)
- [...]
- > (Environment: X11R4pl18, Motif 1.1.5, SunOS 4.1.1, Xsun server and mwm)
-
- > The function (included below), is called from an XmNactivateCallback
- > for a Motif pushButton widget. The callback works as follows:
-
- > busyCursor(topLevel, 1); /* turn on busy cursor */
- > set SIGCHLD to be caught by a function that will turn busyCursor off;
- > fork();
- > if the child process
- > close all fds > 2;
- > exec desired program
- > return;
-
- It is very dangerous to do any X calls from a signal handler; you have
- to make *certain* the signal can't interrupt another X call. (Unless
- you are lucky enough to have a signal-safe Xlib, in which case you're
- asking for portability problems, because most Xlibs aren't.)
-
- In this case, you're getting a very informative error: a BadWindow
- error means that the CreateWindow request was passed a window argument,
- but the argument was not a valid window ID. The CreateWindow request
- takes two window arguments, one of which is the new window's ID,
- generated by Xlib, which hence does not appear at the Xlib call level.
- The other one is the parent window, which in your sample code is given
- as XtWindow(topLevel). I don't really know Xt; from what I've seen fly
- by on the net, I'd guess that perhaps you haven't realized topLevel,
- except that that doesn't make much sense when this is happening in a
- pushbutton callback.
-
- This still leaves it unclear what's going wrong. About all I can
- suggest is running your program under the control of a protocol spy,
- like xscope or xmond, to see what's *really* getting passed, then
- poking around with a debugger to see how come XtWindow(topLevel) is
- that value.
-
- There is one other problem I noticed with your code:
-
- > static Window busyWindow = NULL;
-
- This is definitely wrong, though you will likely get away with it often
- enough to cause trouble. NULL can be any of several things, one of
- which is (void *)0. This is usually incompatible with the Window type.
- What I would recommend is
-
- static Window busyWindow = None;
-
- coupled with a change from
-
- > if (!busyWindow) {
-
- to
-
- if (busyWindow != None) {
-
- Some of this may be excessive paranoia; I'm not sure just how much the
- Xlib interface spec promises....
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-