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 671565 - Styles from style class persist after gtk_style_context_remove_class
Styles from style class persist after gtk_style_context_remove_class
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 669229 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-03-07 15:43 UTC by Peter Hurley
Modified: 2014-07-10 03:25 UTC
See Also:
GNOME target: ---
GNOME version: 3.1/3.2


Attachments
main.c (3.51 KB, text/plain)
2012-03-07 15:44 UTC, Peter Hurley
  Details
[ (1.31 KB, patch)
2012-03-07 18:23 UTC, Peter Hurley
none Details | Review
[RFC 1/1] Remove style class from widget_path also (1.31 KB, patch)
2012-03-07 18:37 UTC, Peter Hurley
none Details | Review

Description Peter Hurley 2012-03-07 15:43:06 UTC
Even after a style class is removed from a style context (with gtk_style_context_remove_class), that style class will continue to contribute styles.

This happens because the style class is never removed from the widget_path element, even when the style_data is rebuilt from scratch in style_data_lookup.

The attached simple testcase highlights the bug.

Although this was discovered and tested for 3.2, a quick perusal of master indicates this bug persists.
Comment 1 Peter Hurley 2012-03-07 15:44:35 UTC
Created attachment 209178 [details]
main.c
Comment 2 Peter Hurley 2012-03-07 18:23:07 UTC
Created attachment 209194 [details] [review]
[
Comment 3 Peter Hurley 2012-03-07 18:37:46 UTC
Created attachment 209196 [details] [review]
[RFC 1/1] Remove style class from widget_path also

** Fat-fingered the earlier attachment description **

This patch removes the style class from the widget_path during gtk_style_context_remove_class.

Although this patch does correct the problem, it may be architecturally unsuitable. Other possible options:
1. Clear the existing style classes from the widget_path head when rebuilding style_data (in create_query_path). The problem with this approach is that it will remove classes that have been added with gtk_widget_path_iter_add_class.
2. Remove only this style class from the widget_path head when rebuilding style_data. Not enough information exists when rebuilding style_data to implement this deferral.
3. Force users of style context to gtk_widget_reset_style whenever removing style classes. Not practical -- besides, if this is required to achieve accurate styling, then it should be done within gtk_style_context_remove_class.
Comment 4 Sebastian 2012-08-26 08:49:54 UTC
Is this bug fixed for 3.6?
Comment 5 Matthias Clasen 2012-08-27 02:13:17 UTC
Thanks for the testcase.
Seems to be reproducible, still.
Comment 6 Benjamin Otte (Company) 2012-09-23 09:06:45 UTC
I think the test is still broken, because 3.6 will not invalidate the style until the next run of gtk_container_idle_sizer().

However, we build widget paths on demand now (and neither use GtkWidget->priv->widget_path nor GtkStyleContext->priv->widget_path anymore), so I think in the real world, this should not happen anymore.
Comment 7 Cosimo Cecchi 2012-10-30 17:18:46 UTC
*** Bug 669229 has been marked as a duplicate of this bug. ***