CList text corruption when executing callback...




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);


The code executes correctly, in that the window/display comes up properly and 
then you can double click on the name in col 0.  You get the expected results 
of the printf function in the callback.  When you click on another name in the 
list, though, you suddenly have garbage displayed on the list.  The NameCopy 
variable and the free (Name) were added in hopes of deleting what appears to 
be a memory trashing problem.  No success.

Comments appreciated.

TIA
   rickf

-- 
Rick Forrister                 <Richard.Forrister@jpl.nasa.gov>

Opera: Greek word meaning "death by music".
		--Anonymous




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