RE: Passing Data to Callbacks



Title: RE: Passing Data to Callbacks

Hello,

Are you sure that you struct scoreinfo si is allocated correctly and that it's not NULL in your callback ?
Try to test the value of your gpointer in the callback to know if it's not NULL

Isabelle




-----Message d'origine-----
De : Adam Tee [mailto:eenajt electeng leeds ac uk]
Envoyé : vendredi 1 février 2002 09:59
À : gtk-app-devel
Objet : Passing Data to Callbacks


Hi,

When I pass some data to a callback and try and access it in the callback
function it is corrupted.  Should the data that is being passed to the
callback be cast using gpointer??  I've tried this and it still doesn't work.
In the function where the menu items are added the data 'struct scoreinfo *si'
is correct.

Here is the connect object function that I'm using and the callback function.

gtk_signal_connect(GTK_OBJECT(menu_item3), "activate",
                            GTK_SIGNAL_FUNC(unhighlight),
                            (struct scoreinfo *)si);
/* callback */
void
unhighlight (gpointer callback_data,GtkWidget * widget)
{
  staffnode *curstaff;
  staff *curstaffstruct;
  measurenode *curmeasure;
  objnode *curobj;
  mudelaobject *mudelaitem;
  /*struct callbackdata *cbdata = (struct callbackdata *)callback_data;*/
  struct scoreinfo *si = (struct scoreinfo *)callback_data;

  for (curstaff = si->thescore; curstaff; curstaff = curstaff->next)
    {
       for (curmeasure = (measurenode *) curstaffstruct->measures;
            curmeasure; curmeasure = curmeasure->next)
       {

          for (curobj = (objnode *)curmeasure->data; curobj;
                curobj = curobj->next)
            {
            mudelaitem = (mudelaobject *)curobj->data;
                ((chord *)mudelaitem->object)->is_highlighted = FALSE;
            }
       }
    }
}

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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