gtk_tree_store_clear segfaults



Dear developers!

When there an at least 3 level deep tree and any node selected under the second level, the gtk_tree_store_clear call segfaults (in other cases segfault may occure, may not). I couldn't figure out why. It looks like an internal list is corrupted. Here is a small program that demonstrates, just select node "Test 3" and press the
"Clear" button. I tried it with GTK+ version 1.3.13 and 1.3.14.


#include <gtk/gtk.h>

static void
on_buttonTreeClear_clicked(GtkButton *button, gpointer user_data)
{
  gtk_tree_store_clear(GTK_TREE_STORE(user_data));
}


int
main (int argc, char *argv[])
{
  GtkWidget *vboxMain;
  GtkWidget *windowMain;
  GtkCellRenderer *cell_rendererMainTree;
  GtkTreeViewColumn *columnMainTree;
  GtkTreeStore *storeMainTree;
  GtkWidget *treeviewMainTree;    GtkWidget *buttonTreeClear;
  GtkTreeIter newiter;
    gtk_init (&argc, &argv);
    windowMain = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (windowMain), "Test");
  gtk_window_set_default_size (GTK_WINDOW (windowMain), 320, 240);
    vboxMain = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vboxMain);
  gtk_container_add (GTK_CONTAINER (windowMain), vboxMain);
    storeMainTree = gtk_tree_store_new(1, G_TYPE_STRING);
treeviewMainTree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (storeMainTree)); cell_rendererMainTree = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (cell_rendererMainTree), "foreground", "black", NULL);
  columnMainTree = gtk_tree_view_column_new_with_attributes ("Test",
                cell_rendererMainTree,
						    "text", 0,
						    NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeviewMainTree), columnMainTree);
  gtk_widget_show (treeviewMainTree);
  gtk_box_pack_start (GTK_BOX (vboxMain), treeviewMainTree, TRUE, TRUE, 0);

  buttonTreeClear = gtk_button_new_with_label ("Clear");
  gtk_widget_show (buttonTreeClear);
  gtk_box_pack_start (GTK_BOX (vboxMain), buttonTreeClear, FALSE, TRUE, 0);

  gtk_signal_connect(GTK_OBJECT (windowMain), "destroy",
                     GTK_SIGNAL_FUNC (gtk_main_quit),
                     NULL);
    gtk_signal_connect (GTK_OBJECT (buttonTreeClear), "clicked",
                      GTK_SIGNAL_FUNC (on_buttonTreeClear_clicked),
                      storeMainTree);

  gtk_tree_store_insert(storeMainTree, &newiter, NULL, 0);
  gtk_tree_store_set(storeMainTree, &newiter, 0, "Test 1", -1);
    gtk_tree_store_insert(storeMainTree, &newiter, &newiter, 0);
  gtk_tree_store_set(storeMainTree, &newiter, 0, "Test 2", -1);
    gtk_tree_store_insert(storeMainTree, &newiter, &newiter, 0);
  gtk_tree_store_set(storeMainTree, &newiter, 0, "Test 3", -1);
    gtk_tree_view_expand_all(GTK_TREE_VIEW(treeviewMainTree));
    gtk_widget_show (windowMain);
    gtk_main();
    return 0;
}


Best regards,
  Chaoron


------------------------------=> http://people.inf.elte.hu/chaoron <=---

 "Software is like sex, it's better when it's free." -- Linus

-----BEGIN GEEK CODE BLOCK-----
GCS/M/S d- s:(-:-) a-- C++(+++)$ ULS++(+++)$ P- L+++ E- W++ N+ o? K? w--
O- M- V PS++ PE++ Y+ PGP>+ t-- 5-- X- R+ tv- b++ DI? D+
G++ e+ h--- r+++ y+++
------END GEEK CODE BLOCK------



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