gnome-settings-daemon r231 - in trunk: . gnome-settings-daemon



Author: mccann
Date: Mon Mar 24 19:45:19 2008
New Revision: 231
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=231&view=rev

Log:
2008-03-24  William Jon McCann  <jmccann redhat com>

	* gnome-settings-daemon/gnome-settings-manager.c:
	(compare_location), (_load_file), (_load_dir):
	* gnome-settings-daemon/gnome-settings-plugin-info.c: (debug_info),
	(gnome_settings_plugin_info_fill_from_file),
	(gnome_settings_plugin_info_deactivate), (load_plugin_module),
	(gnome_settings_plugin_info_activate),
	(gnome_settings_plugin_info_is_active),
	(gnome_settings_plugin_info_get_enabled),
	(gnome_settings_plugin_info_is_available),
	(gnome_settings_plugin_info_get_name),
	(gnome_settings_plugin_info_get_description),
	(gnome_settings_plugin_info_get_authors),
	(gnome_settings_plugin_info_get_website),
	(gnome_settings_plugin_info_get_copyright),
	(gnome_settings_plugin_info_get_location),
	(gnome_settings_plugin_info_get_priority),
	(gnome_settings_plugin_info_set_priority):
	Fix a refcounting bug.  Add a few more checks.  Fix up a leak.
	Fixes #524183



Modified:
   trunk/ChangeLog
   trunk/gnome-settings-daemon/gnome-settings-manager.c
   trunk/gnome-settings-daemon/gnome-settings-plugin-info.c

Modified: trunk/gnome-settings-daemon/gnome-settings-manager.c
==============================================================================
--- trunk/gnome-settings-daemon/gnome-settings-manager.c	(original)
+++ trunk/gnome-settings-daemon/gnome-settings-manager.c	Mon Mar 24 19:45:19 2008
@@ -111,6 +111,10 @@
         loc_a = gnome_settings_plugin_info_get_location (a);
         loc_b = gnome_settings_plugin_info_get_location (b);
 
+        if (loc_a == NULL || loc_b == NULL) {
+                return -1;
+        }
+
         return strcmp (loc_a, loc_b);
 }
 
@@ -175,8 +179,8 @@
                 goto out;
         }
 
-        /* list takes ownership of ref */
-        manager->priv->plugins = g_slist_prepend (manager->priv->plugins, info);
+        manager->priv->plugins = g_slist_prepend (manager->priv->plugins,
+                                                  g_object_ref (info));
 
         g_signal_connect (info, "activated",
                           G_CALLBACK (on_plugin_activated), manager);
@@ -239,8 +243,9 @@
         while ((name = g_dir_read_name (d))) {
                 char *filename;
 
-                if (!g_str_has_suffix (name, PLUGIN_EXT))
+                if (!g_str_has_suffix (name, PLUGIN_EXT)) {
                         continue;
+                }
 
                 filename = g_build_filename (path, name, NULL);
                 if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {

Modified: trunk/gnome-settings-daemon/gnome-settings-plugin-info.c
==============================================================================
--- trunk/gnome-settings-daemon/gnome-settings-plugin-info.c	(original)
+++ trunk/gnome-settings-daemon/gnome-settings-plugin-info.c	Mon Mar 24 19:45:19 2008
@@ -167,6 +167,15 @@
         info->priv->client = gconf_client_get_default ();
 }
 
+static void
+debug_info (GnomeSettingsPluginInfo *info)
+{
+        g_debug ("GnomeSettingsPluginInfo: name='%s' file='%s' location='%s'",
+                 info->priv->name,
+                 info->priv->file,
+                 info->priv->location);
+}
+
 static gboolean
 gnome_settings_plugin_info_fill_from_file (GnomeSettingsPluginInfo *info,
                                            const char              *filename)
@@ -205,13 +214,14 @@
         if ((str != NULL) && (*str != '\0')) {
                 info->priv->location = str;
         } else {
+                g_free (str);
                 g_warning ("Could not find 'Module' in %s", filename);
                 goto out;
         }
 
         /* Get the loader for this plugin */
         str = g_key_file_get_string (plugin_file, PLUGIN_GROUP, "Loader", NULL);
-        if (str && strcmp(str, "python") == 0) {
+        if (str != NULL && strcmp (str, "python") == 0) {
                 info->priv->loader = GNOME_SETTINGS_PLUGIN_LOADER_PY;
 #ifndef ENABLE_PYTHON
                 g_warning ("Cannot load Python plugin '%s' since gnome_settings was not "
@@ -225,7 +235,7 @@
 
         /* Get Name */
         str = g_key_file_get_locale_string (plugin_file, PLUGIN_GROUP, "Name", NULL, NULL);
-        if (str) {
+        if (str != NULL) {
                 info->priv->name = str;
         } else {
                 g_warning ("Could not find 'Name' in %s", filename);
@@ -234,7 +244,7 @@
 
         /* Get Description */
         str = g_key_file_get_locale_string (plugin_file, PLUGIN_GROUP, "Description", NULL, NULL);
-        if (str) {
+        if (str != NULL) {
                 info->priv->desc = str;
         } else {
                 g_debug ("Could not find 'Description' in %s", filename);
@@ -248,7 +258,7 @@
 
         /* Get Copyright */
         str = g_key_file_get_string (plugin_file, PLUGIN_GROUP, "Copyright", NULL);
-        if (str) {
+        if (str != NULL) {
                 info->priv->copyright = str;
         } else {
                 g_debug ("Could not find 'Copyright' in %s", filename);
@@ -256,7 +266,7 @@
 
         /* Get Website */
         str = g_key_file_get_string (plugin_file, PLUGIN_GROUP, "Website", NULL);
-        if (str) {
+        if (str != NULL) {
                 info->priv->website = str;
         } else {
                 g_debug ("Could not find 'Website' in %s", filename);
@@ -272,6 +282,8 @@
 
         g_key_file_free (plugin_file);
 
+        debug_info (info);
+
         /* If we know nothing about the availability of the plugin,
            set it as available */
         info->priv->available = TRUE;
@@ -346,7 +358,7 @@
 gboolean
 gnome_settings_plugin_info_deactivate (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
 
         if (!info->priv->active || !info->priv->available) {
                 return TRUE;
@@ -370,7 +382,7 @@
 
         ret = FALSE;
 
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
         g_return_val_if_fail (info->priv->file != NULL, FALSE);
         g_return_val_if_fail (info->priv->location != NULL, FALSE);
         g_return_val_if_fail (info->priv->plugin == NULL, FALSE);
@@ -504,7 +516,7 @@
 gnome_settings_plugin_info_activate (GnomeSettingsPluginInfo *info)
 {
 
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
 
         if (! info->priv->available) {
                 return FALSE;
@@ -525,7 +537,7 @@
 gboolean
 gnome_settings_plugin_info_is_active (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
 
         return (info->priv->available && info->priv->active);
 }
@@ -533,7 +545,7 @@
 gboolean
 gnome_settings_plugin_info_get_enabled (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
 
         return (info->priv->enabled);
 }
@@ -541,7 +553,7 @@
 gboolean
 gnome_settings_plugin_info_is_available (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, FALSE);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);
 
         return (info->priv->available != FALSE);
 }
@@ -549,7 +561,7 @@
 const char *
 gnome_settings_plugin_info_get_name (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), NULL);
 
         return info->priv->name;
 }
@@ -557,7 +569,7 @@
 const char *
 gnome_settings_plugin_info_get_description (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), NULL);
 
         return info->priv->desc;
 }
@@ -565,7 +577,7 @@
 const char **
 gnome_settings_plugin_info_get_authors (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, (const char **)NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), (const char **)NULL);
 
         return (const char **)info->priv->authors;
 }
@@ -573,7 +585,7 @@
 const char *
 gnome_settings_plugin_info_get_website (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), NULL);
 
         return info->priv->website;
 }
@@ -581,7 +593,7 @@
 const char *
 gnome_settings_plugin_info_get_copyright (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), NULL);
 
         return info->priv->copyright;
 }
@@ -590,7 +602,7 @@
 const char *
 gnome_settings_plugin_info_get_location (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, NULL);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), NULL);
 
         return info->priv->location;
 }
@@ -598,7 +610,7 @@
 int
 gnome_settings_plugin_info_get_priority (GnomeSettingsPluginInfo *info)
 {
-        g_return_val_if_fail (info != NULL, PLUGIN_PRIORITY_DEFAULT);
+        g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), PLUGIN_PRIORITY_DEFAULT);
 
         return info->priv->priority;
 }
@@ -607,7 +619,7 @@
 gnome_settings_plugin_info_set_priority (GnomeSettingsPluginInfo *info,
                                          int                      priority)
 {
-        g_return_if_fail (info != NULL);
+        g_return_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info));
 
         info->priv->priority = priority;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]