I create user_data something like this:
bool
MyTreeModel::iter_nth_root_child_vfunc (int index, iterator & iter) const
{
iter .gobj () -> user_data = new UserData (...);
return true;
}
I can create the user data, but is there a way to get notified when the iterator is destroyed, so I can delete my user data?
No; user_data
is a non-owning pointer. You should parallel the tree with a node-based container (e.g. std::map
) and store your UserData
objects in that, with the user_data
pointer pointing into the container.