gdk_rgb_init calls for robustness
- From: Darin Adler <darin eazel com>
- To: Gtk Developers <gtk-devel-list gnome org>
- Subject: gdk_rgb_init calls for robustness
- Date: Tue, 23 Jan 2001 14:23:45 -0800
gdk_rgb_init is designed so that calling it multiple times is harmless. Some
of the gdk_rgb calls take care of invoking gdk_rgb_init, but others simply
assume it has been called.
For consistency and greater robustness, we just need to add a few more calls
to gdk_rgb_init in the right places.
Here's a patch to do this for the stable branch. I looked over every extern
function and added gdk_rgb_init calls to the 8 functions that depend on
things that gdk_rgb_init sets up, but don't do anything that will guarantee
it's already done.
I'd be happy to write a bug report about this for bugzilla, and/or commit
this change to HEAD or to the stable branch.
If we want to go the other way and reaffirm that we require explicit
gdk_rgb_init calls, an alternative would be to put in return_if_fail calls
that check if image_info is NULL in these same places, to help people notice
when they forget to call gdk_rgb_init.
Please let me know what you'd like me to do.
Index: gdk/gdkrgb.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkrgb.c,v
retrieving revision 1.24.2.3
diff -p -u -r1.24.2.3 gdkrgb.c
--- gdk/gdkrgb.c 2000/11/18 16:59:40 1.24.2.3
+++ gdk/gdkrgb.c 2001/01/23 22:17:44
@@ -726,6 +726,8 @@ gdk_rgb_xpixel_from_rgb (guint32 rgb)
{
gulong pixel = 0;
+ gdk_rgb_init ();
+
if (image_info->bitmap)
{
return ((rgb & 0xff0000) >> 16) +
@@ -2923,7 +2925,7 @@ static gint sincelast;
#undef NO_FLUSH
static gint
-gdk_rgb_alloc_scratch_image ()
+gdk_rgb_alloc_scratch_image (void)
{
if (static_image_idx == N_REGIONS)
{
@@ -3090,6 +3092,7 @@ gdk_draw_rgb_image (GdkDrawable *drawabl
guchar *rgb_buf,
gint rowstride)
{
+ gdk_rgb_init ();
if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
@@ -3114,6 +3117,7 @@ gdk_draw_rgb_image_dithalign (GdkDrawabl
gint xdith,
gint ydith)
{
+ gdk_rgb_init ();
if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
@@ -3136,6 +3140,7 @@ gdk_draw_rgb_32_image (GdkDrawable *draw
guchar *buf,
gint rowstride)
{
+ gdk_rgb_init ();
if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
@@ -3169,6 +3174,8 @@ gdk_draw_gray_image (GdkDrawable *drawab
guchar *buf,
gint rowstride)
{
+ gdk_rgb_init ();
+
if (image_info->bpp == 1 &&
image_info->gray_cmap == NULL &&
(image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
@@ -3195,6 +3202,9 @@ gdk_rgb_cmap_new (guint32 *colors, gint
g_return_val_if_fail (n_colors >= 0, NULL);
g_return_val_if_fail (n_colors <= 256, NULL);
+
+ gdk_rgb_init ();
+
cmap = g_new (GdkRgbCmap, 1);
memcpy (cmap->colors, colors, n_colors * sizeof(guint32));
if (image_info->bpp == 1 &&
@@ -3232,6 +3242,7 @@ gdk_draw_indexed_image (GdkDrawable *dra
gint rowstride,
GdkRgbCmap *cmap)
{
+ gdk_rgb_init ();
if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
@@ -3246,6 +3257,7 @@ gdk_draw_indexed_image (GdkDrawable *dra
gboolean
gdk_rgb_ditherable (void)
{
+ gdk_rgb_init ();
return (image_info->conv != image_info->conv_d);
}
===================================================================
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]