[gnome-color-manager] Ensure we show devices even when the config file is empty or invalid



commit 4014576415a235f504825a0e387b12dc7e879e91
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 24 11:20:29 2009 +0000

    Ensure we show devices even when the config file is empty or invalid

 src/gcm-device.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/gcm-device.c b/src/gcm-device.c
index fd68861..5b66d0b 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -227,9 +227,10 @@ gcm_device_load (GcmDevice *device, GError **error)
 	file = g_key_file_new ();
 	ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error_local);
 	if (!ret) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to load from file: %s", error_local->message);
+		/* not fatal */
+		egg_warning ("failed to load from file: %s", error_local->message);
 		g_error_free (error_local);
+		ret = TRUE;
 		goto out;
 	}
 
@@ -324,10 +325,16 @@ gcm_device_save (GcmDevice *device, GError **error)
 	keyfile = g_key_file_new ();
 	ret = g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error_local);
 	if (!ret) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to load existing config: %s", error_local->message);
-		g_error_free (error_local);
-		goto out;
+		/* empty or corrupt */
+		if (error_local->code == G_KEY_FILE_ERROR_PARSE) {
+			/* ignore */
+			g_clear_error (&error_local);
+		} else {
+			if (error != NULL)
+				*error = g_error_new (1, 0, "failed to load existing config: %s", error_local->message);
+			g_error_free (error_local);
+			goto out;
+		}
 	}
 
 	/* save data */



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