[telepathy-gabble/master] Make GabblePluginLoader a mortal singleton
Will Thompson
will.thompson at collabora.co.uk
Thu Nov 26 09:03:47 PST 2009
<http://bugs.freedesktop.org/show_bug.cgi?id=25205#c1> points out that
making it immortal is a pain for valgrinding, and makes the time of
probing for plugins unpredictable.
---
src/gabble.c | 7 +++++++
src/plugin-loader.c | 12 ++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/gabble.c b/src/gabble.c
index 18ce1ac..209b570 100644
--- a/src/gabble.c
+++ b/src/gabble.c
@@ -32,6 +32,7 @@
#include "debug.h"
#include "connection-manager.h"
+#include "plugin-loader.h"
static TpBaseConnectionManager *
construct_cm (void)
@@ -118,7 +119,9 @@ int
gabble_main (int argc,
char **argv)
{
+ GabblePluginLoader *loader;
int out;
+
tp_debug_divert_messages (g_getenv ("GABBLE_LOGFILE"));
#ifdef ENABLE_DEBUG
@@ -140,9 +143,13 @@ gabble_main (int argc,
tp_debug_set_persistent (TRUE);
#endif
+ loader = gabble_plugin_loader_dup ();
+
out = tp_run_connection_manager ("telepathy-gabble", VERSION,
construct_cm, argc, argv);
+ g_object_unref (loader);
+
#ifdef ENABLE_DEBUG
g_log_set_default_handler (g_log_default_handler, NULL);
g_object_unref (debug_sender);
diff --git a/src/plugin-loader.c b/src/plugin-loader.c
index 026fedd..5a5cdb7 100644
--- a/src/plugin-loader.c
+++ b/src/plugin-loader.c
@@ -158,16 +158,20 @@ gabble_plugin_loader_constructor (
guint n_props,
GObjectConstructParam *props)
{
- static GObject *singleton = NULL;
+ static gpointer singleton = NULL;
if (singleton == NULL)
{
- /* We keep a ref in here to ensure the loader never dies. */
singleton = G_OBJECT_CLASS (gabble_plugin_loader_parent_class)->
constructor (type, n_props, props);
- }
+ g_object_add_weak_pointer (G_OBJECT (singleton), &singleton);
- return g_object_ref (singleton);
+ return singleton;
+ }
+ else
+ {
+ return g_object_ref (singleton);
+ }
}
static void
--
1.5.6.5
More information about the telepathy-commits
mailing list