home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!news.dfrf.nasa.gov!fred.dfrf.nasa.gov!todd
- From: todd@fred.dfrf.nasa.gov (Todd Vernon)
- Subject: Re: Too Big XCreatePixmap returns ? (answers)
- Message-ID: <1993Jan7.164443.2658@news.dfrf.nasa.gov>
- Sender: news@news.dfrf.nasa.gov (Usenet news)
- Reply-To: todd@fred.dfrf.nasa.gov (Todd Vernon)
- Organization: Clarkson
- Date: Thu, 7 Jan 1993 16:44:43 GMT
- Lines: 72
-
- Thanks for the reply's to the question,
-
- >How do I trap for instance BadAlloc as would happen if I ask for
- >a pixmap that is too big ? This seems like a common problem
- >since off screen memory in X Servers is often limited ?
-
- The responces that I have received suggest that BadAlloc on pixmap creates
- are server error events that I can receive a variety of ways using the
- XSetErrorHandler routine. I yield to these peoples experience, however I
- did notice in ORielly VII p409 XSetErrorHandler the paragraph
-
- > The error handler is not called on ... BadAlloc, BadAccess errors.
- > These errors are all indicated by a 0 return value in the
- > corresponding Xlib routines, and can be caught and handled by
- > by the application.
-
- This seems to muddy the water a bit. For information, here is responces
- that I have received. Thanks everyone for the suggestions, anyone elses
- opionion is more then welcome.
-
- todd@fred.dfrf.nasa.gov
- ----------------------------------------------------------------------
-
- The id's are generated on the client, so you will get a good id
- even when the server can't allocate it. The error will get
- returned later.
-
- Here's how I get around it:
- - XSync to process any pending errors
- - save away the current error handler and set a new one
- that looks for badalloc. this function should set
- a flag if badalloc happened.
- - clear the error flag.
- - create the pixmap
- - do an XSync
- - reset the error handler.
- - check the error flag, and handle the error if so.
-
-
-
- Ugly, huh? If you come up with better solutions, I'd like to
- hear them.
-
-
- -brian
- brian.warkentine@eng.sun.com
- ----------------------------------------------------------------------
-
- Here's what to do.
-
- 1) Establish an Xlib error handler.
-
- 2) Do the XCreatePixmap call. Assume it returns a valid
- Pixmap id.
-
- 3) Do XGetGeometry on the Pixmap. If allocation
- failed, you'll drop into the error handler.
-
- 4) Clear the error handler.
-
- oj@roadrunner.pictel.com (Oliver Jones)
-
- ----------------------------------------------------------------------
-
- Bad alloc is a Protocol Error and hence is send to you by the server. What you
- shuold do is to install your own Event Handler function . If no one else tells
- you how to do this email me and I will give you an short exemple.
-
-
- fmhv@minerva.inesc.pt
-
- ----------------------------------------------------------------------
-