Hi, in my application I have a GtkTreeModel which I display in two different places (using two different GtkTreeViews). Therefore, I am using the GtkTreeModelSort widgets to create child model which I can sort independently of each other. The problem when I try to use the mouse wheel to select different rows of the GtkTreeView (see function below). Basically, my logic is as follows: I find the currently active row in the sorted model, I advance the path one up/down (depending on the direction of the scroll) in the sorted model, then I get the corresponding iter in the sorted tree. After that I conver the new iter to the corresponding iter in the original, unsorted model and I change a column value there to indicate that it is the new active row. However, every single time I use the wheel I get the following errors and crash: (gkrellm:12682): Gtk-CRITICAL **: file ../../gtk/gtkliststore.c: line 566 (gtk_list_store_get_value): assertion `GTK_LIST_STORE (tree_model)->stamp == iter->stamp' failed (gkrellm:12682): GLib-GObject-WARNING **: gtype.c:2967: type id `0' is invalid (gkrellm:12682): GLib-GObject-WARNING **: can't peek value table for type `<invalid>' which is not currently referenced Segmentation fault (core dumped) It is even worse if I reorder the model first and the use the wheel. Can anyone help with what I am doing wrong? I am completely unable to debug this as gdb is useless without debugging symbols in GTK and I don''t want to recompile GLib and GTK just to get that. Thanx ------------------------------------------------------- /* Callback for the mouse wheel events */ gint gtodo_mouse_wheel_scrolled (GtkWidget *widget, GdkEventScroll *event, gpointer data) { GtkTreeIter old_iter, new_iter, child_iter,child_old_iter; GtkTreePath *path = NULL; gboolean valid; gboolean active = FALSE; DPRINTF ("in the function..."); /* if we have an active task then we can roll to next/previous one. * otherwise, we set the first one as active */ if (global_config.have_active) { /* get the current task */ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL, (sortmodel),&old_iter); while (valid) { gtk_tree_model_get (GTK_TREE_MODEL (sortmodel), &old_iter, ACTIVE_COLUMN, &active, -1); if (active) break; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (sortmodel),&old_iter); } /* get the path of the active task so we can roll to next one */ path = gtk_tree_model_get_path (GTK_TREE_MODEL (sortmodel),&old_iter); /* check which direction we rolled */ if (event->direction == GDK_SCROLL_UP) /* go to previous task */ gtk_tree_path_prev (path); else if (event->direction == GDK_SCROLL_DOWN) /* go to next task */ gtk_tree_path_next (path); DPRINTF ("changed path..."); if (gtk_tree_model_get_iter (GTK_TREE_MODEL (sortmodel), &new_iter,path)) { gchar *title; glong time; gint comp; gtk_tree_model_get (GTK_TREE_MODEL (sortmodel), &new_iter,TITLE_COLUMN, &title, DEADLINE_COLUMN, &time, COMPLETE_COLUMN,&comp, -1); DPRINTF ("inside update..."); gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT (sortmodel), &child_iter,&new_iter); gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT (sortmodel), &child_old_iter,&old_iter); DPRINTF ("done conversion..."); gtk_list_store_set (GTK_LIST_STORE (task_list_store),&child_old_iter, ACTIVE_COLUMN, FALSE, -1); gtk_list_store_set(GTK_LIST_STORE (task_list_store), &child_iter, ACTIVE_COLUMN, TRUE,-1); DPRINTF ("done edits..."); gtodo_set_panel_tooltip (title, time, comp); DPRINTF ("before comment button..."); gtodo_quick_view_set_comment_button (&new_iter); g_free (title); } DPRINTF ("done active..."); } else { /* we don't already have an active task, so we assume that the first one will be the active * when the wheel is scrolled in either direction */ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(sortmodel), &new_iter)) { gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(sortmodel), &child_iter,&new_iter); gtk_list_store_set (GTK_LIST_STORE (task_list_store),&child_iter, ACTIVE_COLUMN, TRUE, -1); gtodo_quick_view_set_comment_button (&new_iter); global_config.have_active= TRUE; } } global_config.clean = FALSE; DPRINTF ("out of the function..."); return TRUE; } --------------------------------------------------- -- Mitko Haralanov voidtrance at comcast dot net http://voidtrance.home.comcast.net ========================================== grep me no patterns and I'll tell you no lines.
Attachment:
pgpAPD5FyVWc2.pgp
Description: PGP signature