Ethereal-dev: Re: [Ethereal-dev] TCP tools and 8-bit X/window displays

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Tue, 7 Jan 2003 12:58:06 -0800
On Tue, Jan 07, 2003 at 11:19:44AM +0100, Pavel Mores wrote:
> There might be a problem in color-allocating code resulting in drawing
> white foreground on white background.  Colors are allocated by calling
> 
> 	gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE);
> 
> but the return value is not checked (my fault).  Try wrapping this code
> with an 'if' testing the return value.  Although honestly, I don't see
> how could
> 
> 	gdk_color_parse ("black", &color);
> 	gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE);
> 
> (allocating a read-only (=shareable) colorcell for black) fail.

Note that gtk/color.c's "colfilter_init()" allocates black and white;
perhaps the code to handle colors should be made separate from the color
filter code, so it can be used by the color filter code and other
drawing code?

You'd still want to check the success of "gdk_colormap_alloc_color()"
when allocating the various shades of gray - and, for that matter, when
parsing the colors (even if one cannot see how a call can fail, one
should check for its success anyway, if for no other reason than to let
the user know that it failed; one can often be surprised by calls that
"cannot fail" failing for reasons one didn't anticipate).