function_append() returns a pointer to a local variable (row).
That's asking for trouble! I added your code (approximately) to the example program at http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/treeview/list If I let function_append() return &row directly, the compiler (gcc 4.6.1) warns. Your trick of first copying the address to return_row makes the compiler shut up, but the error remains. It's just that the compiler doesn't find it. A solution is to use an iterator instead of a row where possible. Like so: Gtk::TreeModel::iterator function_append() { Gtk::TreeModel::iterator iter = m_refTreeModel->append(); Gtk::TreeModel::Row row = *iter; ...... return iter; } void some_function() { Gtk::TreeModel::iterator iter = function_append(); scroll_to_row(iter); } void scroll_to_row(Gtk::TreeModel::iterator iter) { Gtk::TreeModel::Path path = m_refTreeModel->get_path(iter); m_tree_view->scroll_to_row(path); } 2012-02-10 01:11, kiet tran skrev:
|