home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / 15785 < prev    next >
Encoding:
Text File  |  1992-08-29  |  3.0 KB  |  80 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!stanford.edu!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
  3. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  4. Subject: Re: X Error on busy cursor routine from FAQ
  5. Message-ID: <1992Aug28.085555.7700@thunder.mcrcim.mcgill.edu>
  6. Organization: McGill Research Centre for Intelligent Machines
  7. References: <1992Aug25.224324.7877@asd.com>
  8. Date: Fri, 28 Aug 92 08:55:55 GMT
  9. Lines: 70
  10.  
  11. In article <1992Aug25.224324.7877@asd.com>, scott@asd.com (Scott Barman) writes:
  12.  
  13. > I read the FAQ.  I wanted a busy cursor and have input blocked, so I
  14. > wrote a function based on what I found in FAQ #122.  [...]  However,
  15. > when I run the code I get the following error:
  16.  
  17. > X Error of failed request:  BadWindow (invalid Window parameter)
  18. >   Major opcode of failed request:  1 (X_CreateWindow)
  19. [...]
  20. > (Environment: X11R4pl18, Motif 1.1.5, SunOS 4.1.1, Xsun server and mwm)
  21.  
  22. > The function (included below), is called from an XmNactivateCallback
  23. > for a Motif pushButton widget.  The callback works as follows:
  24.  
  25. >     busyCursor(topLevel, 1);    /* turn on busy cursor */
  26. >     set SIGCHLD to be caught by a function that will turn busyCursor off;
  27. >     fork();
  28. >     if the child process
  29. >         close all fds > 2;
  30. >         exec desired program
  31. >     return;
  32.  
  33. It is very dangerous to do any X calls from a signal handler; you have
  34. to make *certain* the signal can't interrupt another X call.  (Unless
  35. you are lucky enough to have a signal-safe Xlib, in which case you're
  36. asking for portability problems, because most Xlibs aren't.)
  37.  
  38. In this case, you're getting a very informative error: a BadWindow
  39. error means that the CreateWindow request was passed a window argument,
  40. but the argument was not a valid window ID.  The CreateWindow request
  41. takes two window arguments, one of which is the new window's ID,
  42. generated by Xlib, which hence does not appear at the Xlib call level.
  43. The other one is the parent window, which in your sample code is given
  44. as XtWindow(topLevel).  I don't really know Xt; from what I've seen fly
  45. by on the net, I'd guess that perhaps you haven't realized topLevel,
  46. except that that doesn't make much sense when this is happening in a
  47. pushbutton callback.
  48.  
  49. This still leaves it unclear what's going wrong.  About all I can
  50. suggest is running your program under the control of a protocol spy,
  51. like xscope or xmond, to see what's *really* getting passed, then
  52. poking around with a debugger to see how come XtWindow(topLevel) is
  53. that value.
  54.  
  55. There is one other problem I noticed with your code:
  56.  
  57. > static Window   busyWindow = NULL;
  58.  
  59. This is definitely wrong, though you will likely get away with it often
  60. enough to cause trouble.  NULL can be any of several things, one of
  61. which is (void *)0.  This is usually incompatible with the Window type.
  62. What I would recommend is
  63.  
  64. static Window busyWindow = None;
  65.  
  66. coupled with a change from
  67.  
  68. >     if (!busyWindow) {
  69.  
  70. to
  71.  
  72.     if (busyWindow != None) {
  73.  
  74. Some of this may be excessive paranoia; I'm not sure just how much the
  75. Xlib interface spec promises....
  76.  
  77.                     der Mouse
  78.  
  79.                 mouse@larry.mcrcim.mcgill.edu
  80.