[gnome-software] GsPluginLoaderSync: don't iterate the default main context
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] GsPluginLoaderSync: don't iterate the default main context
- Date: Sun, 1 Sep 2013 20:22:05 +0000 (UTC)
commit 0323c2859bc6f062384c73aea1b7c8567637f293
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sat Mar 16 15:39:51 2013 +0100
GsPluginLoaderSync: don't iterate the default main context
The default main context can be iterated only from the default thread
(because it includes Gdk/Gtk sources), so it cannot be used from
threadsafe methods.
https://bugzilla.gnome.org/show_bug.cgi?id=707185
src/gs-plugin-loader-sync.c | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index 301682d..f3e9812 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -27,6 +27,7 @@
typedef struct {
GError **error;
GList *list;
+ GMainContext *context;
GMainLoop *loop;
} GsPluginLoaderHelper;
@@ -52,16 +53,23 @@ gs_plugin_loader_get_installed (GsPluginLoader *plugin_loader,
GsPluginLoaderHelper helper;
/* create temp object */
- helper.loop = g_main_loop_new (NULL, FALSE);
+ helper.context = g_main_context_new ();
+ helper.loop = g_main_loop_new (helper.context, FALSE);
helper.error = error;
+ g_main_context_push_thread_default (helper.context);
+
/* run async method */
gs_plugin_loader_get_installed_async (plugin_loader,
cancellable,
(GAsyncReadyCallback)
gs_plugin_loader_get_installed_finish_sync,
&helper);
g_main_loop_run (helper.loop);
+
+ g_main_context_pop_thread_default (helper.context);
+
g_main_loop_unref (helper.loop);
+ g_main_context_unref (helper.context);
return helper.list;
}
@@ -88,16 +96,23 @@ gs_plugin_loader_get_updates (GsPluginLoader *plugin_loader,
GsPluginLoaderHelper helper;
/* create temp object */
- helper.loop = g_main_loop_new (NULL, FALSE);
+ helper.context = g_main_context_new ();
+ helper.loop = g_main_loop_new (helper.context, FALSE);
helper.error = error;
+ g_main_context_push_thread_default (helper.context);
+
/* run async method */
gs_plugin_loader_get_updates_async (plugin_loader,
cancellable,
(GAsyncReadyCallback) gs_plugin_loader_get_updates_finish_sync,
&helper);
g_main_loop_run (helper.loop);
+
+ g_main_context_pop_thread_default (helper.context);
+
g_main_loop_unref (helper.loop);
+ g_main_context_unref (helper.context);
return helper.list;
}
@@ -124,16 +139,23 @@ gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
GsPluginLoaderHelper helper;
/* create temp object */
- helper.loop = g_main_loop_new (NULL, FALSE);
+ helper.context = g_main_context_new ();
+ helper.loop = g_main_loop_new (helper.context, FALSE);
helper.error = error;
+ g_main_context_push_thread_default (helper.context);
+
/* run async method */
gs_plugin_loader_get_popular_async (plugin_loader,
cancellable,
(GAsyncReadyCallback) gs_plugin_loader_get_popular_finish_sync,
&helper);
g_main_loop_run (helper.loop);
+
+ g_main_context_pop_thread_default (helper.context);
+
g_main_loop_unref (helper.loop);
+ g_main_context_unref (helper.context);
return helper.list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]