home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / 20859 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.8 KB  |  84 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!news.dfrf.nasa.gov!fred.dfrf.nasa.gov!todd
  3. From: todd@fred.dfrf.nasa.gov (Todd Vernon)
  4. Subject: Re: Too Big XCreatePixmap returns ? (answers)
  5. Message-ID: <1993Jan7.164443.2658@news.dfrf.nasa.gov>
  6. Sender: news@news.dfrf.nasa.gov (Usenet news)
  7. Reply-To: todd@fred.dfrf.nasa.gov (Todd Vernon)
  8. Organization: Clarkson
  9. Date: Thu, 7 Jan 1993 16:44:43 GMT
  10. Lines: 72
  11.  
  12. Thanks for the reply's to the question,
  13.  
  14.     >How do I trap for instance BadAlloc as would happen if I ask for
  15.     >a pixmap that is too big ?  This seems like a common problem
  16.     >since off screen memory in X Servers is often limited ?
  17.  
  18. The responces that I have received suggest that BadAlloc on pixmap creates
  19. are server error events that I can receive a variety of ways using the
  20. XSetErrorHandler routine.  I yield to these peoples experience, however I
  21. did notice in ORielly VII p409 XSetErrorHandler the paragraph
  22.  
  23.     > The error handler is not called on ... BadAlloc, BadAccess errors.
  24.     > These errors are all indicated by a 0 return value in the 
  25.     > corresponding Xlib routines, and can be caught and handled by
  26.         > by the application.
  27.  
  28. This seems to muddy the water a bit.  For information, here is responces
  29. that I have received.  Thanks everyone for the suggestions, anyone elses
  30. opionion is more then welcome.
  31.  
  32. todd@fred.dfrf.nasa.gov
  33. ----------------------------------------------------------------------
  34.  
  35.     The id's are generated on the client, so you will get a good id
  36.     even when the server can't allocate it.  The error will get
  37.     returned later.
  38.  
  39.     Here's how I get around it:
  40.     -    XSync to process any pending errors
  41.     -    save away the current error handler and set a new one
  42.         that looks for badalloc.  this function should set
  43.         a flag if badalloc happened.
  44.     -    clear the error flag.
  45.     -    create the pixmap
  46.     -    do an XSync
  47.     -    reset the error handler.
  48.     -    check the error flag, and handle the error if so.
  49.         
  50.  
  51.  
  52.     Ugly, huh?  If you come up with better solutions, I'd like to
  53.     hear them.
  54.  
  55.  
  56. -brian
  57. brian.warkentine@eng.sun.com
  58. ----------------------------------------------------------------------
  59.  
  60. Here's what to do.
  61.  
  62. 1) Establish an Xlib error handler.
  63.  
  64. 2) Do the XCreatePixmap call.  Assume it returns a valid
  65.    Pixmap id. 
  66.  
  67. 3) Do XGetGeometry on the Pixmap.  If allocation
  68.    failed, you'll drop into the error handler.
  69.  
  70. 4) Clear the error handler.
  71.  
  72. oj@roadrunner.pictel.com (Oliver Jones)
  73.  
  74. ----------------------------------------------------------------------
  75.  
  76. Bad alloc is a Protocol Error and hence is send to you by the server. What you
  77. shuold do is to install your own Event Handler function . If no one else tells
  78. you how to do this email me and I will give you an short exemple.
  79.  
  80.  
  81. fmhv@minerva.inesc.pt
  82.  
  83. ----------------------------------------------------------------------
  84.