GNOME Bugzilla – Bug 758442
gtk_style_context_save() destroys style information
Last modified: 2016-03-02 20:09:14 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.
Indeed. We failed to copy the name properly on save(). But only in the case of using widget paths.