Re: gtk_tree_model_get_iter segfault in on_row_activated
- From: blythe2 tcnj edu
- To: "Christopher Backhouse" <cjbackhouse gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gtk_tree_model_get_iter segfault in on_row_activated
- Date: Fri, 16 Jun 2006 13:59:52 -0400 (EDT)
Iter needs to be an actual object, not just a pointer. You are *creating*
a n iterator, then passing it by reference to be filled. As your code
stands now, you're passing an uninitialized pointer to be written to,
which of course crashes. Try the following:
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";
}
That should work better. Hope that helps!
-Nate
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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]