Re: [gtk-list] Bug in gtkclist: cell_set_text and friends.



> In the copy of gtkclist.c I have, cell_set_text cell_set_pixtext, and
> perhaps others all free the current string before storing the new
> one.  This makes the following code segfault:
> 
>   gtk_clist_get_text(cl, row, col, &text);
>   ...
>   gtk_clist_set_text(cl, row, col, text);
> 
> Is this intentional?  It seems reasonable to have gtk_clist_set*text()
> check to see if the string argument is the same pointer the one
> already in the cell.  If so, then it shouldn't try to free it.

Yes, it's intentional.  I also think it's "the right behavior".  Changing
it for this one case doesn't make much sense to me, but shouldn't hurt
anything.

> 
> Now I know that the above code is just a no-op, but aside from making
> the interface more robust, and keeping the user from having to check
> all the pointers carefully, what about the case where you're trying to
> change a cell from text to pixtext like this:
> 

>   gtk_clist_get_text(cl, row, col, &text);
    text = g_strdup (text);
>   gtk_clist_set_pixtext(cl, row, col, text, spacing, pixmap, mask);
    g_free (text);

> I believe this will also segfault.
  Now it won't.



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