[gnome-settings-daemon] Don't choke if there are old plugins laying around
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Don't choke if there are old plugins laying around
- Date: Thu, 14 Oct 2010 06:37:19 +0000 (UTC)
commit 18e57e126ff6a6ab2980c119aebef087227e2a54
Author: William Jon McCann <jmccann redhat com>
Date: Thu Oct 14 02:36:28 2010 -0400
Don't choke if there are old plugins laying around
Noticed this because the typing monitor plugin was still in my
install directory.
gnome-settings-daemon/gnome-settings-manager.c | 45 ++++++++++++++++----
gnome-settings-daemon/gnome-settings-plugin-info.c | 10 +++-
2 files changed, 43 insertions(+), 12 deletions(-)
---
diff --git a/gnome-settings-daemon/gnome-settings-manager.c b/gnome-settings-daemon/gnome-settings-manager.c
index 1aa7efc..f691dce 100644
--- a/gnome-settings-daemon/gnome-settings-manager.c
+++ b/gnome-settings-daemon/gnome-settings-manager.c
@@ -146,6 +146,26 @@ on_plugin_deactivated (GnomeSettingsPluginInfo *info,
g_signal_emit (manager, signals [PLUGIN_DEACTIVATED], 0, name);
}
+static gboolean
+contained (const char * const *items,
+ const char *item)
+{
+ while (*items) {
+ if (g_strcmp0 (*items++, item) == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+is_schema (const char *schema)
+{
+ return contained (g_settings_list_schemas (), schema);
+}
+
+
static void
_load_file (GnomeSettingsManager *manager,
const char *filename)
@@ -169,18 +189,25 @@ _load_file (GnomeSettingsManager *manager,
goto out;
}
- manager->priv->plugins = g_slist_prepend (manager->priv->plugins,
- g_object_ref (info));
-
- g_signal_connect (info, "activated",
- G_CALLBACK (on_plugin_activated), manager);
- g_signal_connect (info, "deactivated",
- G_CALLBACK (on_plugin_deactivated), manager);
-
key_name = g_strdup_printf ("%s.plugins.%s",
DEFAULT_SETTINGS_PREFIX,
gnome_settings_plugin_info_get_location (info));
- gnome_settings_plugin_info_set_settings_prefix (info, key_name);
+
+ /* Ignore unknown schemas or else we'll assert */
+ if (is_schema (key_name)) {
+ manager->priv->plugins = g_slist_prepend (manager->priv->plugins,
+ g_object_ref (info));
+
+ g_signal_connect (info, "activated",
+ G_CALLBACK (on_plugin_activated), manager);
+ g_signal_connect (info, "deactivated",
+ G_CALLBACK (on_plugin_deactivated), manager);
+
+ gnome_settings_plugin_info_set_settings_prefix (info, key_name);
+ } else {
+ g_warning ("Ignoring unknown module '%s'", key_name);
+ }
+
/* Priority is set in the call above */
g_free (key_name);
diff --git a/gnome-settings-daemon/gnome-settings-plugin-info.c b/gnome-settings-daemon/gnome-settings-plugin-info.c
index df3a876..5ec0f54 100644
--- a/gnome-settings-daemon/gnome-settings-plugin-info.c
+++ b/gnome-settings-daemon/gnome-settings-plugin-info.c
@@ -115,7 +115,9 @@ gnome_settings_plugin_info_finalize (GObject *object)
g_free (info->priv->copyright);
g_strfreev (info->priv->authors);
- g_object_unref (info->priv->settings);
+ if (info->priv->settings != NULL) {
+ g_object_unref (info->priv->settings);
+ }
G_OBJECT_CLASS (gnome_settings_plugin_info_parent_class)->finalize (object);
}
@@ -328,8 +330,10 @@ gnome_settings_plugin_info_set_settings_prefix (GnomeSettingsPluginInfo *info,
if (priority > 0)
info->priv->priority = priority;
- g_signal_connect (G_OBJECT (info->priv->settings), "changed",
- G_CALLBACK (plugin_enabled_cb), info);
+ g_signal_connect (G_OBJECT (info->priv->settings),
+ "changed",
+ G_CALLBACK (plugin_enabled_cb),
+ info);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]