Blame SOURCES/0001-Resolves-rhbz-1404656-crash-on-opening-second-evince.patch

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