[gnome-color-manager/gnome-3-8] Make it work with dispcal using stderr



commit d37843ea6a25d62509aba887fb50e333e63c254a
Author: Patryk Zawadzki <patrys room-303 com>
Date:   Thu Dec 5 16:41:41 2013 +0100

    Make it work with dispcal using stderr
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gcm-calibrate-argyll.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 2bb402c..fd52586 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -160,7 +160,9 @@ gcm_calibrate_argyll_get_display (const gchar *output_name,
 {
        gboolean ret = FALSE;
        gchar *command = NULL;
-       gchar *data = NULL;
+       const gchar *data;
+       gchar *data_stderr = NULL;
+       gchar *data_stdout = NULL;
        gchar *name;
        gchar **split = NULL;
        gint exit_status;
@@ -174,13 +176,26 @@ gcm_calibrate_argyll_get_display (const gchar *output_name,
 
        /* execute it and capture stderr */
        ret = g_spawn_command_line_sync (command,
-                                        NULL,
-                                        &data,
+                                        &data_stdout,
+                                        &data_stderr,
                                         &exit_status,
                                         error);
        if (!ret)
                goto out;
 
+       /* recent versions of dispcal switched to stderr output */
+       if (data_stdout != NULL && data_stdout[0] != '\0') {
+               data = data_stdout;
+       } else if (data_stderr != NULL && data_stderr[0] != '\0') {
+               data = data_stderr;
+       } else {
+               g_set_error_literal (error,
+                                    GCM_CALIBRATE_ERROR,
+                                    GCM_CALIBRATE_ERROR_INTERNAL,
+                                    "no sensible output from dispcal");
+               goto out;
+       }
+
        /* split it into lines */
        split = g_strsplit (data, "\n", -1);
        for (i=0; split[i] != NULL; i++) {
@@ -210,7 +225,8 @@ gcm_calibrate_argyll_get_display (const gchar *output_name,
        }
 out:
        g_free (command);
-       g_free (data);
+       g_free (data_stdout);
+       g_free (data_stderr);
        g_strfreev (split);
        return display;
 }


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