Re: [gtk-list] CList text corruption when executing callback...
- From: Roger Books <books mail state fl us>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] CList text corruption when executing callback...
- Date: Tue, 14 Apr 1998 13:21:43 -0400 (EDT)
When you attach something to a clist it just stores the pointer, so
if you take a buffer, write something to it, and then store it to
the clist data, then take the same buffer and write something new
to it, then store it to the next clist items data, both will be the
same since they are working with the same pointer.
What I am doing is malloc()ing a region of memory for each item, then
when the clist is destroyed free()ing the pointers then.
Roger
>
> I am getting corruption of the text displayed in a clist after double
> clicking on any item in the clist. The code fragments are:
>
> The callback function is:
> ------------------------
>
> void rpmCListCallback (GtkCList *clist, gint row, gint col,
> GdkEvent *event, gpointer data) {
> char *Name=calloc (50, sizeof(char));
> char *NameCopy;
>
> if (event->type == GDK_2BUTTON_PRESS)
> {
> gtk_clist_get_text (GTK_CLIST(rpmCList), row, col, &Name);
> NameCopy = strdup (Name);
> free (Name);
> printf ("rpmCList: double click on row=%d, col=%d, RPM=%s\n",
> row, col, NameCopy);
> }
>
> }
>
> and the link for the signal is made by:
> --------------------------------------
>
> gtk_signal_connect (GTK_OBJECT(rpmCList), "select_row",
> (GtkSignalFunc) rpmCListCallback, NULL);
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]