After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 142599 - Inappropriate implementation of Gtk::TreeIter::operator bool()
Inappropriate implementation of Gtk::TreeIter::operator bool()
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: TreeView
2.4
Other All
: Normal major
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-05-16 04:32 UTC by Daniel Elstner
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel Elstner 2004-05-16 04:32:10 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.
Comment 1 Daniel Elstner 2004-05-18 20:03:53 UTC
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.