Re: Getting crazy with GtkCTree widget



Wolfgang Sourdeau wrote:

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.


  Well this works and doesn't work. I mean: I have changed this and it
hasn't run, but when I have changed the order of the calls in the other
function I sent you, it has worked. I have put this funtion call first
and the others under this, and it seems to work properly.

  Another thing. I have passed **data because this is the type of arg
that comes in proto of gtk_ctree_get_node_info and because this function
should return not only first column but all of the columns of the node
(created with gtk_ctree_insert_node). I'm still thinking that something
is broken in this widget :-|

  Well, Million Thanks for your help! :)

--------------
José Carlos García Sogo
 jsogo arrakis es




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