Re: Getting crazy with GtkCTree widget



La plume légère, à Tue, Sep 26, 2000 at 05:16:35PM +0200, heure d'inpiration,
José Carlos García Sogo écrivait en ces mots:
  This function returns me the node ok. Then I want, for example, get
the data stored in first column of the row. So I call this other
function:
gchar *
keymanager_get_username_from_node (GtkCTreeNode* node)
{
   gchar **data;
                 
   if (node != NULL)
      gtk_ctree_get_node_info (GTK_CTREE(keylist), node, data,
NULL,NULL,NULL,NULL,NULL,NULL,NULL);

   return data[0];
}

You should probably modify that function to make it look
like this:

gchar *
keymanager_get_username_from_node (GtkCTreeNode* node)
{
        gchar *data;

        if (node != NULL)
                gtk_ctree_get_node_info (GTK_CTREE(keylist), node, &data,
                                NULL,NULL,NULL,NULL,NULL,NULL,NULL);

        return data;
}

gchar **data is a pointer to a pointer with an underfined value.
So when you call gtk_ctree_get_node_info with it as an arg,
gtk_ctree_get_node_info will modify the pointer pointed by "data", that is,
at an undefined location in mem.

OTHO, gchar *data is just a simple pointer. When you pass "&data" as an argument,
gtk_ctree_get_node_info will modify the value of "data" and
not the value of an undefined address. This, because not only "&data" is "known"
but "data" too whereas in you version only "data" (equiv. to "&data") is known.


Wolfgang
-- 
A chicken is an egg's way of producing more eggs.




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