[gnome-color-manager] Don't segfault when we add a saved xrandr device with not output name
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Don't segfault when we add a saved xrandr device with not output name
- Date: Sun, 22 Nov 2009 16:35:12 +0000 (UTC)
commit 0b54dd5d4e50fb05098cc946b559c1fe6295d014
Author: Richard Hughes <richard hughsie com>
Date: Sun Nov 22 16:34:21 2009 +0000
Don't segfault when we add a saved xrandr device with not output name
src/gcm-prefs.c | 32 ++++++++++++++++++++------------
src/gcm-utils.c | 7 +++++++
2 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 6cf9302..440afa5 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -890,27 +890,35 @@ gcm_prefs_add_device_xrandr (GcmDevice *device)
gchar *title;
gchar *id;
gboolean ret;
+ gboolean connected;
GError *error = NULL;
/* get details */
g_object_get (device,
"id", &id,
+ "connected", &connected,
"title", &title_tmp,
NULL);
- /* set the gamma on the device */
- ret = gcm_utils_set_gamma_for_device (device, &error);
- if (!ret) {
- egg_warning ("failed to set output gamma: %s", error->message);
- g_error_free (error);
- }
+ /* italic for non-connected devices */
+ if (connected) {
+ /* set the gamma on the device */
+ ret = gcm_utils_set_gamma_for_device (device, &error);
+ if (!ret) {
+ egg_warning ("failed to set output gamma: %s", error->message);
+ g_error_free (error);
+ }
- /* use a different title if we have crap xorg drivers */
- if (ret) {
- title = g_strdup (title_tmp);
+ /* use a different title if we have crap xorg drivers */
+ if (ret) {
+ title = g_strdup (title_tmp);
+ } else {
+ /* TRANSLATORS: this is where an output is not settable, but we are showing it in the UI */
+ title = g_strdup_printf ("%s\n(%s)", title_tmp, _("No hardware support"));
+ }
} else {
- /* TRANSLATORS: this is where an output is not settable, but we are showing it in the UI */
- title = g_strdup_printf ("%s\n(%s)", title_tmp, _("No hardware support"));
+ /* TRANSLATORS: this is where the device has been setup but is not connected */
+ title = g_strdup_printf ("%s <i>[%s]</i>", title_tmp, _("disconnected"));
}
/* add to list */
@@ -1280,7 +1288,7 @@ gcm_prefs_add_device_type (GcmDevice *device)
/* italic for non-connected devices */
if (!connected) {
/* TRANSLATORS: this is where the device has been setup but is not connected */
- g_string_append_printf (string, " <i>[%s]</i>", _("Currently disconnected"));
+ g_string_append_printf (string, " <i>[%s]</i>", _("disconnected"));
}
/* use a different title for stuff that won't work yet */
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 80576f8..48888d5 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -254,6 +254,13 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
goto out;
}
+ /* should be set for display types */
+ if (output_name == NULL) {
+ if (error != NULL)
+ *error = g_error_new (1, 0, "no output name for display: %s", id);
+ goto out;
+ }
+
/* check we have an output */
rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, error);
if (rr_screen == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]