[gnome-color-manager] trivial: Ensure we're working with GcmDeviceXrandr devices before we try to set the gamma



commit 2fb0e7e435400122652ab7fc5bb0965b9e2e7a41
Author: Richard Hughes <richard hughsie com>
Date:   Sat Feb 6 13:23:59 2010 +0000

    trivial: Ensure we're working with GcmDeviceXrandr devices before we try to set the gamma

 src/gcm-client.c        |    5 ++++-
 src/gcm-device-xrandr.c |    2 +-
 src/gcm-prefs.c         |    7 +++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 471e7c9..d67ed43 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -580,7 +580,10 @@ gcm_client_add_unconnected_device (GcmClient *client, GKeyFile *keyfile, const g
 	type = gcm_device_type_enum_from_string (type_text);
 
 	/* create device */
-	device = gcm_device_new ();
+	if (type == GCM_DEVICE_TYPE_ENUM_DISPLAY)
+		device = gcm_device_xrandr_new ();
+	else
+		device = gcm_device_new ();
 	g_object_set (device,
 		      "type", type,
 		      "id", id,
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index b8bc70a..218ed72 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -467,7 +467,7 @@ gcm_device_xrandr_set_gamma (GcmDeviceXrandr *device_xrandr, GError **error)
 	}
 
 	/* should be set for display types */
-	if (output_name == NULL) {
+	if (output_name == NULL || output_name[0] == '\0') {
 		g_set_error (error, 1, 0, "no output name for display: %s", id);
 		goto out;
 	}
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 9598877..11793dc 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -1932,6 +1932,12 @@ gcm_prefs_add_device_xrandr (GcmDevice *device)
 	gboolean connected;
 	GError *error = NULL;
 
+	/* sanity check */
+	if (!GCM_IS_DEVICE_XRANDR (device)) {
+		egg_warning ("not a xrandr device");
+		goto out;
+	}
+
 	/* get details */
 	g_object_get (device,
 		      "id", &id,
@@ -1973,6 +1979,7 @@ gcm_prefs_add_device_xrandr (GcmDevice *device)
 			    GCM_DEVICES_COLUMN_SORT, sort,
 			    GCM_DEVICES_COLUMN_TITLE, title,
 			    GCM_DEVICES_COLUMN_ICON, "video-display", -1);
+out:
 	g_free (id);
 	g_free (sort);
 	g_free (title_tmp);



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