[gtkmm] Problem with TreeModelColumn types



Hi,

I have some problems with the TreeView resp. the TreeModel and I hope
anyone can give me a hint.

When I construct a TreeModel::ColumnRecord with columns of type
  Gtk::TreeModelColumn<Glib::ustring>
or
  Gtk::TreeModelColumn<int>
I don't have any problems. But when I'm using
  Gtk::TreeModelColumn<Category> //Category is a custom class
I get segfaults under some circiumstances.

When I set a column-value in a row and read the same value everything
works fine:

row[categoryTreeColumns->catFields] =
	CategoryFields::getCategoryFields(rootCategory.cat_fields);     
std::vector<CategoryField> catFields =
	row[categoryTreeColumns->catFields];

But when I try to access the same value in the same row afterwards I get
a segfault:

Glib::RefPtr<Gtk::TreeSelection> selection =
	categoriesTreeView->get_selection();    
const Gtk::TreeRow &selectedRow	= 
	*(selection->get_selected());    
std::vector<CategoryField> catFields = 
	selectedRow[categoryTreeColumns->catFields];

The segfault occurs in 
  Gtk::TreeRow::get_value_impl(int, Glib::ValueBase&) const ()

The custom class is:
class CategoryField{
public:
    CategoryField();
    CategoryField(const CategoryField&);
    CategoryField(const field&);
     CategoryField &operator=(const CategoryField &cat);
    
    std::string name;
    std::string nameTranslated;
    std::string content;     
};

And the TreeModel::ColumnRecord:
class CategoryTreeColumns : public Gtk::TreeModel::ColumnRecord{
public:
    CategoryTreeColumns(){ add(categoryName);
	add(translatedCatName); add(catFields); }               
    Gtk::TreeModelColumn<Glib::ustring> categoryName;      
    Gtk::TreeModelColumn<Glib::ustring> translatedCatName;      
    Gtk::TreeModelColumn< std::vector<CategoryField> > catFields;    
};

And I'm using the the Debian packets from unstable:
libgtkmm2.0-1c102 2.2.11-1      
libgtkmm2.0-dev   2.2.11-1

I hope my description of the problem is detailled enough.

Thanks in advance,
Johannes



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