GNOME Bugzilla – Bug 757397
gtk_widget_set_name() doesn't properly refresh the style
Last modified: 2015-11-01 01:43:42 UTC
Created attachment 314523 [details] example reproducing the bug Setting the CSS ID (`gtk_widget_set_name()`) on a widget doesn't trigger a repaint even when required. OTOH, setting a CSS class does work properly. Interestingly, unsetting the ID (`gtk_widget_set_name(widget, NULL)`) properly refreshes, but not setting one (i.e. `gtk_widget_set_name(widget, "dummy")`). Attached a small test case reproducing the issue. If all worked OK, the text should blink red. You can build with `-DUSE_STYLE_CLASS` to use style classes instead of IDs, which makes the example work as expected. Tested broken on 3.18.0 and Git HEAD; 3.16.0 worked. Adding `GTK_CSS_CHANGE_ID` to `GTK_CSS_RADICAL_CHANGE` in `gtkcssnode.c` fixes (or works around) the issue; but I don't have enough clues about this code to know whether this would be a sensible fix. If it is though, it might be sensible to use `GTK_CSS_CHANGE_ANY_SELF` instead, as it has the same value and (to my eyes) might make sense.
Just finished bisecting, and the offending commit is https://git.gnome.org/browse/gtk%2B/commit/?id=4ebb5781eaf332da3f8ce5ffb5ecc8668a56f118 So I suspect the solution of adding `GTK_CSS_CHANGE_ID` to `GTK_CSS_RADICAL_CHANGE` is correct, and probably also the one of using `GTK_CSS_CHANGE_ANY_SELF` directly.
Created attachment 314561 [details] [review] cssnode: Fix style updating when the CSS node ID changes Proposed patch fixing the issue. I also altered gtkcsswidgetnode.c in the same way just in case as it probably suffers from similar issues (as NAME used to include ID), although it doesn't seem to be required to fix the actual issue I'm seeing. I can remove this change if it's deemed unnecessary and/or incorrect. (In reply to Colomban Wendling from comment #0) > If it is though, it might be sensible to use `GTK_CSS_CHANGE_ANY_SELF` instead, as it has the same value and (to my eyes) might make sense. Scratch that, it was too late for my eyes to see only the first few constants were the same, the value of those are actually totally different.
Attachment 314561 [details] pushed as f4c3006 - cssnode: Fix style updating when the CSS node ID changes