Expand the row to make children visible in the treeview crashes the application

I have two section

  1. Drawing Area
  2. TreeView

Whenever I finish drawing a rectangle I add the drawing into the child like this

|-> Rectangle 1


After appending the name to the child

  rowSp = *(treeViewPointer->append(rowSp.children()));
  rowSp[treeViewPointer->treeColumn.col_name] = RectangleName;

When I call treeView->expand_to_path(spPath);

The application crashes.

but when I used the same expand_to_path after inserting the child and click on the rectangle the row expands.

What am i doing wrong here ?

I reference this expand_to_path

I found this on stackover flow Python GTK3 - Programtically selecting a node in TreeView after search?

one of the comments says

You are correct. I freed the path by Gtk.TreeModel - Interfaces - Gtk 3.0. I got segment fault. If I didn’t free the path, it was Ok. The document sounds not correct (maybe copy from GTK+)

This is the extract thing happening to me I am getting segmentation fault

this is the python code that seems to work fine

    def findSelectNode( self, text ):
        # BUG: Only by name for now.
        tree_iter = self.findNodeByDescription( text )
        if ( tree_iter != None ):
            print("###### SELECTING ROW" )
            path = self.tree_store.get_path( tree_iter )
            self.tree_view.expand_to_path( path )               # expand the whole branch
            self.tree_view.get_selection().select_path( path )  # select it

How do I get path from iter in C++?

I tired this

          const Gtk::TreeModel::iterator sIter = iter;
          selectedPath = Gtk::TreeModel::get_path(sIter);

I get this error

*.cpp:1496:56: error: cannot call member function Gtk::TreeModel::Path Gtk::TreeModel::get_path(const iterator&) const without object
selectedPath = Gtk::TreeModel::get_path(sIter);

What am I doing wrong?

Gtk::TreeModel::get_path() is not a static member function. You can’t call it like that.
You must do something like

 selectedPath = tree_store->get_path(sIter);

I assume that you’ve got a TreeStore object.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.