[gtkmm] Erasing TreeModel rows...



Hey,

I've been following the documentation and examples online and in the
distribution. They are helpful, but a little unclear about removing rows
from TreeModels. Here is the function that I have attempting to do the
dirty work.

void MyTreeView::deleteRow(Glib::ustring title)
{
  Gtk::TreeModel::Children children = treestore->children();

  for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter
!= children.end(); ++iter)
  {
    Gtk::TreeModel::Row row = *iter;
    if (row[columns.m_col_name] == title) {

      ////
      // Segfaults on this erase line. "treestore" is declared as 
      // Glib::RefPtr<Gtk::TreeStore> treestore; 
      // and is a protected member of the MyTreeView class.
      ////
      treestore->erase(iter);
      break;
    }
  }
}

When execution gets to the point of failure (the erase statement), the
iter is in fact valid and is at correct row. I can print out information
stored on that row, this is why I'm certain. Execution does not get
beyond that line.

I've looked around for row removal examples, and had no luck. Anyone
here have any pointers? 

Thanks.
~djc





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