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 765921 - css colour lookup failure after gtk_style_context_save
css colour lookup failure after gtk_style_context_save
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.20.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-05-03 02:42 UTC by Morten Welinder
Modified: 2018-05-02 17:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test program (4.78 KB, text/plain)
2016-05-03 02:42 UTC, Morten Welinder
Details

Description Morten Welinder 2016-05-03 02:42:45 UTC
Created attachment 327190 [details]
Test program

With upcoming test program I get...

welinder@lenovo ~/gtkwork/gtk+-3.20.3/tests $ make testcalendar && ../libtool --mode=execute ./testcalendar 
  CC       testcalendar.o
testcalendar.c: In function ‘main’:
testcalendar.c:61:16: warning: offset outside bounds of constant string [enabled by default]
       selector = next + 1;
                ^
  CCLD     testcalendar
colour=rgb(255,0,0)
colour=rgb(46,52,54)        <--- Would you look at that!
colour=rgb(255,0,0)


(The warning is inside code copied from foreigndrawing.c; I think gcc is
wrong here.)

I don't see any reason why I should get a different colour just because the
style context has been saved.

This is with stock gtk+ 3.20.3

Bug 758442 seems related, but that is claimed to be fixed.
Comment 1 Matthias Clasen 2016-05-03 10:52:33 UTC
whats going on here is that gtk_style_context_save() creates a transient subnode of the current node. This sometimes has unexpected effects as you can see here. If you add a selector like "button.itembar * { color: blue; }" you will find that it matches inside the save/restore.
Comment 2 Morten Welinder 2016-05-03 11:35:33 UTC
> ...creates a transient subnode...

Isn't that an implementation detail that I shouldn't need to know about?

And if I should know, it probably should be prominently spelled out as
part of the documentation for gtk_style_context_save.  It is currently
described as a purely state saving method.

Note, that this means that anyone following the advice on
https://blogs.gnome.org/mclasen/2015/11/20/a-gtk-update/
regarding get_color (i.e., use save+set_state+get_color+restore)
will get the wrong colour.
Comment 3 Morten Welinder 2016-05-03 11:51:57 UTC
Also, in my example, shouldn't the transient subnode inherit the colour
setting of button.itembar?
Comment 4 GNOME Infrastructure Team 2018-05-02 17:06:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/621.