GNOME Bugzilla – Bug 142599
Inappropriate implementation of Gtk::TreeIter::operator bool()
Last modified: 2004-12-22 21:47:04 UTC
Apparently, using operator bool() on a virgin Gtk::TreeIter isn't valid anymore, though it used to work with gtkmm 2.2. I get the following runtime warning: (regexxer:25515): gtkmm-WARNING **: Gtk::TreeIter::operator bool(): defaulting to false because this iterator has no TreeModel. By looking at the source code I discovered that operator bool() is now implemented via TreeModel::iter_is_valid(). In regexxer's case, this in turn results in a call to gtk_tree_store_iter_is_valid(). The GTK+ documentation for this function says: WARNING: This function is slow. Only use it for debugging and/or testing purposes. This is no laughing matter. Looking at gtktreestore.c, I see that gtk_tree_store_iter_is_valid() performs a linear search of the entire tree for the given iterator. On top of that, operator bool() is most likely used within loops that iterate over the tree's content. Given all these problems, I propose to revert to the original implementation of TreeIter::operator bool(). This can be done without breaking API nor ABI.
Fix committed to CVS: 2004-05-18 Daniel Elstner <daniel.elstner@gmx.net> * gtk/src/treeiter.ccg (TreeIter::operator bool): Put the original test for gobject_.stamp != 0 back in place. The iter_is_valid() method provided by model implementations is intended for debugging purposes only, and thus should not be used here (bug #142599). * gtk/src/treemodel.hg (TreeModel::iter_is_valid): Document that the usage of this method as abstract interface is deprecated, and that the implementation's iter_is_valid() should be used directly.