From 786f778b71849c755cce31eb08972d46770f10a8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 31 Aug 2016 10:39:57 -0700 Subject: [PATCH] Save and restore GtkStyleContext in a few places that were not doing it Does not fix any known problem, but seems prudent (backport of 5d04f41d47de8161c1653255666e3f4e7b508228) --- src/gtk/control.cpp | 2 ++ src/gtk/window.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index f11b6e80ed..c418af212c 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -250,6 +250,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, stateFlag = GTK_STATE_FLAG_ACTIVE; } GtkStyleContext* sc = gtk_widget_get_style_context(widget); + gtk_style_context_save(sc); GdkRGBA c; gtk_style_context_set_state(sc, stateFlag); gtk_style_context_get_color(sc, stateFlag, &c); @@ -260,6 +261,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, gtk_style_context_get( sc, stateFlag, GTK_STYLE_PROPERTY_FONT, &info.description, NULL); attr.font = wxFont(info); + gtk_style_context_restore(sc); #else GtkStyle* style; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8920d55a22..d27f889f59 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -304,8 +304,10 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) #ifdef __WXGTK3__ GtkStyleContext* sc = gtk_widget_get_style_context(win->m_wxwindow); GdkRGBA c; + gtk_style_context_save(sc); gtk_style_context_set_state(sc, GTK_STATE_FLAG_NORMAL); gtk_style_context_get_border_color(sc, GTK_STATE_FLAG_NORMAL, &c); + gtk_style_context_restore(sc); gdk_cairo_set_source_rgba(cr, &c); cairo_set_line_width(cr, 1); cairo_rectangle(cr, x + 0.5, y + 0.5, w - 1, h - 1); @@ -4444,9 +4446,11 @@ void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3( cairo_pattern_t* pattern = NULL; if (m_backgroundColour.IsOk()) { + gtk_style_context_save(context); gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL); gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, "background-image", &pattern, NULL); + gtk_style_context_restore(context); } if (pattern) {