From ca83dd9054abdaae93308f27bdf927e050230027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 10 Jan 2017 12:04:58 +0000 Subject: [PATCH] Resolves: rhbz#1404656 crash on opening second evince window e.g. export G_SLICE=always-malloc open https://www.antennahouse.com/XSLsample/pdf/sample-link_1.pdf right click on the first link and open in new window close the new window repeat crash This is similar to https://bugzilla.gnome.org/show_bug.cgi?id=726812 --- shell/ev-window.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/shell/ev-window.c b/shell/ev-window.c index 11f2fd5..a648ed7 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -6666,10 +6666,32 @@ _gtk_css_provider_load_from_resource (GtkCssProvider *provider, } static void +ev_window_init_css (void) +{ + static gsize initialization_value = 0; + + if (g_once_init_enter (&initialization_value)) { + GtkCssProvider *css_provider; + GError *error = NULL; + + css_provider = gtk_css_provider_new (); + _gtk_css_provider_load_from_resource (css_provider, + "/org/gnome/evince/ui/evince.css", + &error); + g_assert_no_error (error); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (css_provider); + + g_once_init_leave (&initialization_value, 1); + } +} + +static void ev_window_init (EvWindow *ev_window) { GtkBuilder *builder; - GtkCssProvider *css_provider; GError *error = NULL; GtkWidget *sidebar_widget; GtkWidget *overlay; @@ -6748,15 +6770,7 @@ ev_window_init (EvWindow *ev_window) actions, G_N_ELEMENTS (actions), ev_window); - css_provider = gtk_css_provider_new (); - _gtk_css_provider_load_from_resource (css_provider, - "/org/gnome/evince/ui/evince.css", - &error); - g_assert_no_error (error); - gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (ev_window)), - GTK_STYLE_PROVIDER (css_provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - g_object_unref (css_provider); + ev_window_init_css (); ev_window->priv->recent_manager = gtk_recent_manager_get_default (); -- 2.9.3