Re: gtk_tree_model_filter_set_modify_func()



Tim Müller wrote:
On Tuesday 29 June 2004 18:25, Russell Shaw wrote:

In the following code, i can only get printed on the terminal window:
  n:0 val:(null)
I should get:
  n:0 val:abc

If i comment out the gtk_tree_model_filter_set_modify_func() line
then it works. What am i doing wrong? Gtk 2.4.3


... snip ...

void filtermodifyfunc(
                      GtkTreeModel *model,
                      GtkTreeIter *iter,
                      GValue *value,
                      gint column,
                      gpointer data)
{
    return;
}


you're supposed to set the value to something in that function, otherwise it will just stay initialised to 0/NULL ....

When i get the value to modify with gtk_tree_model_get() in the code below, it
seems to recursively call filtermodifyfunc() and the process repeats until a
segfault:

void filtermodifyfunc(
                      GtkTreeModel *model,
                      GtkTreeIter *iter,
                      GValue *value,
                      gint column,
                      gpointer data)
{
    g_printf("passed\n");
    if(G_VALUE_HOLDS_STRING(value)){
        gchar *str;
        gtk_tree_model_get(model,iter,column,&str,-1);
        g_value_set_string(value,str);
        g_printf(col:%d val:%s\n",column,str);
    }
    else if(G_VALUE_HOLDS_UINT(value)){
        guint n;
        gtk_tree_model_get(model,iter,column,&n,-1);
        g_value_set_uint(value,n);
        g_printf(col:%d n:%u\n",column,n);
    }
}



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