[gnome-color-manager] trivial: don't explode if a device has no assigned profiles



commit abf40a1fa7ab7d63342b7d00ac5d1cea80ceae02
Author: Richard Hughes <richard hughsie com>
Date:   Wed May 26 16:07:55 2010 +0100

    trivial: don't explode if a device has no assigned profiles

 src/gcm-device.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/gcm-device.c b/src/gcm-device.c
index a94eeac..a2570ea 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -643,18 +643,20 @@ gcm_device_load (GcmDevice *device, GError **error)
 
 	/* parse filenames to object, skipping entries that fail to parse */
 	profile_filenames = g_key_file_get_string_list (file, priv->id, "profile", NULL, NULL);
-	for (i=0; profile_filenames[i] != NULL; i++) {
-		file_tmp = g_file_new_for_path (profile_filenames[i]);
-		profile = gcm_profile_default_new ();
-		ret = gcm_profile_parse (profile, file_tmp, &error_local);
-		if (ret) {
-			g_ptr_array_add (priv->profiles, g_object_ref (profile));
-		} else {
-			egg_warning ("failed to parse %s: %s", profile_filenames[i], error_local->message);
-			g_clear_error (&error_local);
+	if (profile_filenames != NULL) {
+		for (i=0; profile_filenames[i] != NULL; i++) {
+			file_tmp = g_file_new_for_path (profile_filenames[i]);
+			profile = gcm_profile_default_new ();
+			ret = gcm_profile_parse (profile, file_tmp, &error_local);
+			if (ret) {
+				g_ptr_array_add (priv->profiles, g_object_ref (profile));
+			} else {
+				egg_warning ("failed to parse %s: %s", profile_filenames[i], error_local->message);
+				g_clear_error (&error_local);
+			}
+			g_object_unref (profile);
+			g_object_unref (file_tmp);
 		}
-		g_object_unref (profile);
-		g_object_unref (file_tmp);
 	}
 
 	if (priv->serial == NULL)



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