GNOME Bugzilla – Bug 99035
list_store.clear() followed by list_store.append() segfaults
Last modified: 2004-12-22 21:47:04 UTC
Modify the example under examples/book/treeview/list/examplewindow.cc to clear the list before appending rows: //Create the Tree model: m_refTreeModel = Gtk::ListStore::create(m_Columns); m_TreeView.set_model(m_refTreeModel); + m_refTreeModel.clear(); + //Fill the TreeView's model Gtk::TreeModel::Row row = *(m_refTreeModel->append()); row[m_Columns.m_col_id] = 1; row[m_Columns.m_col_name] = "Billy Bob"; Then the append causes a segmentation fault. I got this with my own program, too. This is with gtkmm 2.0.0. I've tried modifying the paned.c example from GTK+ to include the line "gtk_list_store_clear(model);", which works. So it's probably not a GTK+ bug.
Hmm, m_refTreeModel.clear(); invokes Glib::RefPtr<Gtk::ListStore>::clear(), which unreferences the object and unsets the pointer :) Cheers, --Daniel
Argh. Note to self: never mix copy-paste of code with typedefs that prevent you from seeing what kind of types you're working with. Sorry.