fg, bg color of tooltips



Hi.

I've one question about the design of the function

void
gtk_tooltips_set_colors (GtkTooltips *tooltips,
			 GdkColor    *background,
			 GdkColor    *foreground)
{
  g_return_if_fail (tooltips != NULL);

  if (background != NULL)
    tooltips->foreground = foreground;
  if (foreground != NULL)
    tooltips->background = background;
}

Shouldn't this function duplicate the background and foreground colors
given as parameters instead of just copying the pointer value? (i.e.
if (foreground != NULL)
{
  if (tooltips->foreground == NULL)
    tooltips->foreground = g_malloc (sizeof (GdkColor));
  *tooltips->foreground = *foreground;
}
So one can use this function in the following (intended?) way:

GdkColor    green = {0, 0, 0xffff, 0};

gtk_tooltips_set_colors (tips, &green, &green);

Otherwise there's a memory leak: neither the user nor gtk can free the
memory if the widget has been destroyed (o.k. just 4 ints;).

BTW: The if conditions in function gtk_tooltips_draw_tips() 
	line 446: if (tooltips->background != NULL)
	line 460: if (tooltips->foreground != NULL)
should be replaced by
if (tooltips->background != NULL && tooltips->foreground != NULL)

Regards,

Ullrich

P.S.: I use gtk+ 0.99.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]