gtk_tree_model_get_iter segfault in on_row_activated



I have connected to the row activated signal and want to handle it - so I am doing this:

void on_row_activated(GtkTreeView* tree_view,GtkTreePath* path,GtkTreeViewColumn* column,gpointer user_data)
{
        std::cout<<"path was "<<gtk_tree_path_to_string(path)<<"\n";
        GtkTreeModel* model=gtk_tree_view_get_model(tree_view);
        if(model!=NULL)
                std::cout<<"got the model OK\n";
        else
                std::cout<<"failed to get the model\n";
        std::cout<<"trying to get the iter\n";
        GtkTreeIter* iter;
        if(gtk_tree_model_get_iter(model,iter,path)==TRUE)
                std::cout<<"got the iter ok\n";
        else
                std::cout<<"didn't get the iter\n";
}

upon double-clicking an item in the list output looks something like (in this case the 4th entry)

path was 3
got the model OK
trying to get the iter
Segmentation fault

although bizarrely it very occasionally works fine.

Any ideas? It's a bit impolite to segfault when all the parameters I pass are at least existing



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