[gnome-software] Fix threadsafety issues with gtk icon theme use
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix threadsafety issues with gtk icon theme use
- Date: Tue, 22 Apr 2014 11:14:52 +0000 (UTC)
commit 199757279be079ae8c4317a6a078eb58c5f71649
Author: Kalev Lember <kalevlember gmail com>
Date: Tue Apr 22 11:45:19 2014 +0200
Fix threadsafety issues with gtk icon theme use
Instead of using global icon theme, create our own icon theme singleton
and use that. Having our own makes it easy to serialize access to it
when we need to load icons from several threads at a time.
src/gs-utils.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index aba511f..4b4edee 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -247,6 +247,18 @@ gs_mkdir_parent (const gchar *path, GError **error)
return ret;
}
+static GtkIconTheme *icon_theme_singleton;
+static GMutex icon_theme_lock;
+
+static GtkIconTheme *
+icon_theme_get (void)
+{
+ if (icon_theme_singleton == NULL)
+ icon_theme_singleton = gtk_icon_theme_new ();
+
+ return icon_theme_singleton;
+}
+
/**
* gs_pixbuf_load:
**/
@@ -269,12 +281,14 @@ gs_pixbuf_load (const gchar *icon_name, guint icon_size, GError **error)
icon_size,
error);
} else if (g_strstr_len (icon_name, -1, ".") == NULL) {
- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ g_mutex_lock (&icon_theme_lock);
+ pixbuf = gtk_icon_theme_load_icon (icon_theme_get (),
icon_name,
icon_size,
GTK_ICON_LOOKUP_USE_BUILTIN |
GTK_ICON_LOOKUP_FORCE_SIZE,
error);
+ g_mutex_unlock (&icon_theme_lock);
} else {
g_set_error (error,
GS_PLUGIN_ERROR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]