Re: [gtk-list] CTree confusion/bug



On Thu, Apr 22, 1999 at 04:01:16PM +0100, Lee wrote:

> I've run into some confusion while using the CTree widget.
> What I wish to do is a gtk_ctree_post_recursive call on a node, which
> will then refresh the pixmap of that node (leaving the text label
> intact), according to some condition.
> 
> However, the result I get is that the pixmap is changed, but the labels
> are for the most part completely garbled.

You have to copy the cell text first.

>    /* Get everything about the node except the pixmaps */
>    gtk_ctree_get_node_info (GTK_CTREE (tree),
> 			    GTK_CTREE_NODE (node),
> 			    &node_text, &spaces,
> 			    NULL, NULL, NULL, NULL,
> 			    &is_a_leaf, &open);

only returns a pointer to the cell text, so

>    /* Dependant upon state, change the node's pixmap fields */
>    if (state == 1) {
>       gtk_ctree_set_node_info (GTK_CTREE (tree), 
> 			       GTK_CTREE_NODE (node),
> 			       node_text,
> 			       spaces, orange_file, orange_file_map,
> 			       orange_file, orange_file_map,
> 			       is_a_leaf, open);

frees node_text first and then tries to g_strdup (node_text)...
You should call g_strdup yourself and free the allocated string
after the gtk_ctree_set_node_info call.

bye,
  Lars



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