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 758442 - gtk_style_context_save() destroys style information
gtk_style_context_save() destroys style information
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-11-21 00:49 UTC by Michael Catanzaro
Modified: 2016-03-02 20:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Modified version of Ben's test program (1.90 KB, text/x-csrc)
2015-11-21 00:49 UTC, Michael Catanzaro
Details

Description Michael Catanzaro 2015-11-21 00:49:30 UTC
Created attachment 315998 [details]
Modified version of Ben's test program

I'm trying to render a GtkEntry with gtk_render_background() and gtk_render_frame() -- trying to fix WebKit to work with GTK+ 3.19.2.

Ben Otte wrote a nice test program that allows me to track where particular theme colors are coming from. I'll attach the full program, modified to reproduce this bug, but the gist of it is:

  path = gtk_widget_path_new ();
  gtk_widget_path_append_type (path, GTK_TYPE_ENTRY);
  gtk_widget_path_iter_set_object_name (path, -1, "entry");

  context = gtk_style_context_new ();
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  gtk_style_context_print_interesting_sections (context);

That all works fine, and prints this:

  background-color: gtk-contained.css:171:31
  background-image: gtk-contained.css:172:81
  color: gtk-contained.css:173:14

Now, if I call gtk_style_context_save (context), the style gets "destroyed":

  gtk_style_context_save (context);
  gtk_style_context_print_interesting_sections (context);

  background-color: ---
  background-image: ---
  color: ---

Another call to gtk_style_context_restore (context) brings back the style. It seems unexpected that calling gtk_style_context_save() causes theme information to be lost.

WebKit is using save/restore in order to cache one GtkStyleContext per widget type, instead of creating a new GtkStyleContext each time it wants to render a widget.
Comment 1 Benjamin Otte (Company) 2015-11-21 01:24:19 UTC
Indeed. We failed to copy the name properly on save(). But only in the case of
using widget paths.