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 662177 - Toolbar returns invalid paths for toolbar items
Toolbar returns invalid paths for toolbar items
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkToolbar
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-10-19 11:00 UTC by Stef Walter
Modified: 2011-11-14 10:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtk: GtkToolbar returns invalid paths when adding tool items (2.62 KB, patch)
2011-10-19 11:20 UTC, Stef Walter
none Details | Review
gtk: GtkToolbar returns invalid paths when adding tool items (4.19 KB, patch)
2011-10-20 09:13 UTC, Stef Walter
accepted-commit_now Details | Review

Description Stef Walter 2011-10-19 11:00:54 UTC
In certain cases GtkToolbar returns invalid widget paths for toolbar items. This has to do with adding invisible toolbar items, as done by GtkUiManager.

I had a hard time making a simple test case, but this is easily demonstrated by running the glade application.

Warnings like this are output:

(glade:15517): Gtk-CRITICAL **: gtk_style_provider_get_style_property: assertion `g_type_is_a (gtk_widget_path_get_object_type (path), pspec->owner_type)' failed

Putting the following assertion at the end of gtk_toolbar_get_path_for_child() reports that indeed invalid paths are being returned:

  g_assert (gtk_widget_path_get_object_type (path) == G_OBJECT_TYPE (child));
Comment 1 Stef Walter 2011-10-19 11:20:20 UTC
Created attachment 199417 [details] [review]
gtk: GtkToolbar returns invalid paths when adding tool items

 * Fix problems where gtk_toolbar_get_path_for_child() returns invalid
   paths, because content has changed since siblings_path was calculated
Comment 2 Benjamin Otte (Company) 2011-10-19 11:27:45 UTC
Isn't gtk_toolbar_invalidate_siblings() the exact same thing as gtk_toolbar_invalidate_order()?

And if so, isn't adding a call to gtk_toolbar_invalidate_order() in toolbar_content_remove()  enough to fix the problem?
Comment 3 Stef Walter 2011-10-19 12:20:18 UTC
(In reply to comment #2)
> Isn't gtk_toolbar_invalidate_siblings() the exact same thing as
> gtk_toolbar_invalidate_order()?

Well it invalidate_siblings() doesn't call gtk_widget_reset_styles() for all children.

> And if so, isn't adding a call to gtk_toolbar_invalidate_order() in
> toolbar_content_remove()  enough to fix the problem?

No toolbar content is being removed in this case.

Note that the expensive gtk_widget_reset_styles() is being called all over the place, and it asks for widget paths. For example gtk_widget_set_parent() ends up calling reset_styles().

So essentially priv->sibling_path seems to be set in unexpected places when the toolbar is in an interim state. That interim sibling_paths is then not cleared out. This is what it seems to me, but you might understand it better.

So the reason for splitting invalidate_siblings() out from invalidate_order() is that this doesn't cause yet more unnecessary reset_styles() churn.
Comment 4 Stef Walter 2011-10-20 09:13:47 UTC
Created attachment 199506 [details] [review]
gtk: GtkToolbar returns invalid paths when adding tool items

* Calculate siblings_path on demand, so that it's always correct
   and doesn't get out of sync with the toolbar state.
Comment 5 Benjamin Otte (Company) 2011-10-20 09:26:30 UTC
Comment on attachment 199506 [details] [review]
gtk: GtkToolbar returns invalid paths when adding tool items

This sounds like the easiest solution for the problem, so let's go with it.
Comment 6 Stef Walter 2011-10-20 12:49:48 UTC
Thanks. Merged into master. Can I backport this into gtk-3-2 branch?
Comment 7 Benjamin Otte (Company) 2011-10-20 20:17:41 UTC
Please do.
Comment 8 Stef Walter 2011-10-24 08:50:27 UTC
I tried cherry-picking these two commits to the gtk-3-2 branch, but it didn't fix the problem. Can you think of any other commits that need to be back ported?


commit 43afb192f20af925b16aa13e8d3f6122954ab2f1
Author: Stef Walter <stefw@collabora.co.uk>
Date:   Wed Oct 19 13:17:18 2011 +0200

    gtk: GtkToolbar returns invalid paths when adding tool items
    
     * Calculate siblings_path on demand, so that it's always correct
       and doesn't get out of sync with the toolbar state.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=662177

commit ad389880850607129d87823d3ed605bc4e598aca
Author: Benjamin Otte <otte@redhat.com>
Date:   Tue Sep 27 04:29:55 2011 +0200

    toolbar: Fix widget path creation code
    
    - Ensure arrow button is always included
    - Invalidate list when direction changes
Comment 9 Benjamin Otte (Company) 2011-10-24 17:57:55 UTC
No idea. And I'm on vacation still, so I have the luxury to not care. ;)
Poke me next week, if I forget about it please.
Comment 10 Stef Walter 2011-11-01 13:35:22 UTC
Pokedy poke :)
Comment 11 Cosimo Cecchi 2011-11-07 22:20:47 UTC
I pushed those commits to gtk-3-2, since I just tested them to work properly on a clean build/installation; Stef, it's possible you still had the old .so lurking in your library path? Anyway, closing as FIXED, feel free to reopen if this is an issue again.
Comment 12 Stef Walter 2011-11-14 10:18:57 UTC
That did the trick. Yeah, it's possible I screwed up on my jhbuild directory. Thanks!