From: Daniel A. S. <st...@ic...> - 2004-03-19 03:16:23
|
Jim, On Friday, Mar 19, 2004, at 14:04 Australia/Sydney, Jim Ingham wrote: > Aren't you already using the obdata field for that purpose? not exactly, I'm using obdata to keep track of the pixmap in the case where the XImage has been copied from screen with GetImage. However I think the core uses other XImages where image->data is just a manually allocated GWorld, which has be handled differently (e.g. in Get/SetPixel, use 8 bit color data instead of 16 bit like for images copied off screen). I haven't really verified this in depth though. > I think we are already going to get into trouble if anybody sets > this behind our back. So perhaps we can rely on that being non-null > for cases where we made out of CGraf's of some sort. > > The other option is to call IsValidPort on the data from the image, > and if it is not a valid port, then treat it as a malloc'ed data > buffer. IsValidPort seems reliable - QD keeps a list of ports, and > checks against that. So maybe that would be a good way to do it? that sounds like the safe way to go about it, indeed anywhere we currently assume image->data is a port, we should probably be calling ValidPort and either deal with failures with alternative code or at least panic instead of crashing... > It's a bit amusing that QDDebugPrintPortInfo doesn't call IsValidPort, > but just tries to print the port anyway. I checked the code, and > indeed that is true... But it is just a debugging function. maybe still worth a radar... it can be annyoing if you segfault just because you mistype a port addr in gdb, I've had that happen while I was fiddling with the Get/PutImage stuff Cheers, Daniel -- ** Daniel A. Steffen ** "And now for something completely ** Dept. of Mathematics ** different" Monty Python ** Macquarie University ** <mailto:st...@ma...> ** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/> |