Re: testgtk crashes in bsearch



When running testtreeview I got the message

testtreeview (pid:5486): GRuntime-CRITICAL **: file gparam.c: line 166 
(g_param_spec_ref): assertion `G_IS_PARAM_SPEC (pspec)' failed

Making the change below got rid of it. May I commit?

Padraig

Index: gtkstyle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
retrieving revision 1.77
diff -u -p -r1.77 gtkstyle.c
--- gtkstyle.c  2001/09/10 10:54:43     1.77
+++ gtkstyle.c  2001/09/10 12:10:34
@@ -1300,13 +1300,13 @@ _gtk_style_peek_property_value (GtkStyle
   g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), 
NULL);
   g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
 
+  key.widget_type = widget_type;
+  key.pspec = pspec;
   /* need value cache array */
   if (!style->property_cache)
     style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
   else
     {
-      key.widget_type = widget_type;
-      key.pspec = pspec;
       pcache = bsearch (&key,
                        style->property_cache->data, style->property_cache->len,
                        sizeof (PropertyValue), style_property_values_cmp);


> To: "Padraig O'Briain" <Padraig Obriain sun com>
> Cc: gtk-devel-list gnome org
> Subject: Re: testgtk crashes in bsearch
> User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
> MIME-Version: 1.0
> 
> 
> "Padraig O'Briain" <Padraig Obriain Sun COM> writes:
> 
> > Following up on my own mail.
> > 
> > I have found that the following change fixes the problem. May I commit?
> >
> > cvs server: Diffing .
> > Index: gtkstyle.c
> > ===================================================================
> > RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
> > retrieving revision 1.76
> > diff -u -p -r1.76 gtkstyle.c
> > --- gtkstyle.c  2001/09/08 17:55:02     1.76
> > +++ gtkstyle.c  2001/09/10 10:03:03
> > @@ -1307,12 +1307,16 @@ _gtk_style_peek_property_value (GtkStyle
> >    /* lookup, or insert value if not yet present */
> >    key.widget_type = widget_type;
> >    key.pspec = pspec;
> > -  pcache = bsearch (&key,
> > -                   style->property_cache->data, style->property_cache->len,
> > -                   sizeof (PropertyValue), style_property_values_cmp);
> > -  if (pcache)
> > -    return &pcache->value;
> >  
> > +  if (style->property_cache->len > 0)
> > +  {
> > +    /* On Solaris bsearch does not check that the length is non-zero */
> > +    pcache = bsearch (&key,
> > +                     style->property_cache->data, 
style->property_cache->len,
> > +                     sizeof (PropertyValue), style_property_values_cmp);
> > +    if (pcache)
> > +      return &pcache->value;
> > +  }
> >    i = 0;
> >    while (i < style->property_cache->len &&
> >          style_property_values_cmp (&key, &g_array_index 
(style->property_cache, 
> > PropertyValue, i)) >= 0)
> 
> I've committed the following patch which is perhaps marginally 
> more elegant.
> 
> Thanks for finding this,
>                                         Owen
> 
> Index: gtk/gtkstyle.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
> retrieving revision 1.76
> diff -u -r1.76 gtkstyle.c
> --- gtk/gtkstyle.c	2001/09/08 17:55:02	1.76
> +++ gtk/gtkstyle.c	2001/09/10 10:52:53
> @@ -1303,15 +1303,16 @@
>    /* need value cache array */
>    if (!style->property_cache)
>      style->property_cache = g_array_new (FALSE, FALSE, sizeof 
(PropertyValue));
> -
> -  /* lookup, or insert value if not yet present */
> -  key.widget_type = widget_type;
> -  key.pspec = pspec;
> -  pcache = bsearch (&key,
> -		    style->property_cache->data, style->property_cache->len,
> -		    sizeof (PropertyValue), style_property_values_cmp);
> -  if (pcache)
> -    return &pcache->value;
> +  else
> +    {
> +      key.widget_type = widget_type;
> +      key.pspec = pspec;
> +      pcache = bsearch (&key,
> +			style->property_cache->data, style->property_cache->len,
> +			sizeof (PropertyValue), style_property_values_cmp);
> +      if (pcache)
> +	return &pcache->value;
> +    }
>  
>    i = 0;
>    while (i < style->property_cache->len &&





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