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 399615 - Certain gtk_tree_model_iter_* methods changed behavior
Certain gtk_tree_model_iter_* methods changed behavior
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.10.x
Other All
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2007-01-23 00:34 UTC by Stew Benedict
Modified: 2007-03-15 02:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
possible patch (469 bytes, patch)
2007-01-25 11:16 UTC, Stew Benedict
none Details | Review

Description Stew Benedict 2007-01-23 00:34:57 UTC
Please describe the problem:
We have encountered a change in behavior for the above function, in the LSB lsb-test-desktop.  This has been reported by a runtime tester, and I believe I've verified the behavior has changed:

http://bugs.linuxbase.org/show_bug.cgi?id=1547

Basically, the test creates a tree store and then 5 elements with 5 children each, then tests for iter 1:5, expecting FALSE. (more info/code at the url above)


Steps to reproduce:
Run the test case attached in the LSB bugzilla url above.
 
 


Actual results:


Expected results:
check for iter 1:5 returns FALSE 

Does this happen every time?
yes

Other information:
Comment 1 Stew Benedict 2007-01-24 17:47:34 UTC
fix summary
Comment 2 Stew Benedict 2007-01-25 11:16:14 UTC
Created attachment 81166 [details] [review]
possible patch

I assume there's probably a better fix that could be implemented within gtk_tree_store_iter_nth_child().
Comment 3 Kristian Rietveld 2007-01-27 17:52:56 UTC
When you call the _iter_* functions through gtk_tree_model_iter_* the iter is first initialized (to something invalid) and then the corresponding gtk_tree_store_iter_* function is called.  GTK+ has been changed to directly call the gtk_tree_store_iter_* functions in gtktreestore.c internally in revision 14518.  This caused the iters to not be initialized anymore; and the gtk_tree_store_iter_* functions do not make the iter invalid when returning FALSE, which is in disagreement with the docs which state that the iter is set to be invalid when FALSE is returned.

There are two ways to fix this:
  a) modify gtk_tree_store_iter_* to set the iter to something invalid when returning FALSE (in this case we also need to check whether any internal code relies on this, and other tree models need updating too).
  b) reverting r14518 in places where this forms a problem (for example in gtk_tree_store_get_iter()).


I think I would prefer b).  Matthias, what do you think?


(That said, I think the vts test should actually check the return value of gtk_tree_model_get_iter_from_string instead of using iter_is_valid).

Comment 4 Matthias Clasen 2007-01-27 19:47:44 UTC
I still think that the test is not backed by the documentation, and I agree
that the test needs to check the return value of gtk_tree_model_get_iter_from_string().

/**
 * gtk_tree_model_get_iter_from_string:
 * @tree_model: A #GtkTreeModel.
 * @iter: An uninitialized #GtkTreeIter.
 * @path_string: A string representation of a #GtkTreePath.
 *
 * Sets @iter to a valid iterator pointing to @path_string, if it
 * exists. Otherwise, @iter is left invalid and %FALSE is returned.
 *
 * Return value: %TRUE, if @iter was set.
 **/

It could be clearer, but IMO "left" indicates that the function is free
not to touch the iter if it returns FALSE. Also, if you look at the implementation, it simply calls gtk_tree_model_get_iter():

/**
 * gtk_tree_model_get_iter:
 * @tree_model: A #GtkTreeModel.
 * @iter: The uninitialized #GtkTreeIter.
 * @path: The #GtkTreePath.
 *
 * Sets @iter to a valid iterator pointing to @path.
 *
 * Return value: %TRUE, if @iter was set.
 **/

Here the documentation is even clearer, a return value of FALSE means
you cannot rely on iter to be set to anything, valid or invalid.

Comment 5 Kristian Rietveld 2007-01-27 20:25:21 UTC
Ah yes, a small oversight from me.  For example the gtk_tree_model_iter_nth_child() docs explicitly state that the iter is set to to be invalid; and this is still working fine.

I agree that the current code is working according to the documentation then, and would propose to resolve this bug as NOTABUG.
Comment 6 Stew Benedict 2007-01-30 11:34:03 UTC
Thanks for the feedback. The test suite has been corrected as of 3.1.1-3 to use the return value from gtk_tree_model_get_iter_from_string()