summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-07-29 14:34:34 +0100
committerRichard Hughes <richard@hughsie.com>2013-07-29 14:36:15 +0100
commit0baa06134a86b493a07156531ade5fc15b26618c (patch)
tree02ba3210cbdae383ac062bb57c0ba2ed15af36c1 /lib
parent28f39449afd40efacb9dec0bac387dd5b5093124 (diff)
downloadcolord-0baa06134a86b493a07156531ade5fc15b26618c.tar.gz
libcolord: Work around a bug in cmsSaveProfileToMem()
We'll go back to the proper method when the upstream bug has been found and fixed.
Diffstat (limited to 'lib')
-rw-r--r--lib/colord/cd-icc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/colord/cd-icc.c b/lib/colord/cd-icc.c
index 7cd1600..3d3a0e4 100644
--- a/lib/colord/cd-icc.c
+++ b/lib/colord/cd-icc.c
@@ -27,6 +27,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <lcms2.h>
#include <string.h>
#include <stdlib.h>
@@ -1558,6 +1559,7 @@ cd_icc_serialize_profile (CdIcc *icc, GError **error)
gboolean ret;
GBytes *data = NULL;
gchar *data_tmp = NULL;
+#if 0
cmsUInt32Number length = 0;
/* get size of profile */
@@ -1593,6 +1595,31 @@ cd_icc_serialize_profile (CdIcc *icc, GError **error)
"failed to dump ICC file to memory");
goto out;
}
+#else
+ const gchar *temp_file = "/tmp/profile.icc";
+ gsize length;
+
+ /* LCMS2 doesn't serialize some tags properly when using the function
+ * cmsSaveProfileToMem() twice, so until that's fixed we have to use a
+ * temporary file */
+ ret = cmsSaveProfileToFile (priv->lcms_profile, temp_file);
+ if (!ret) {
+ g_set_error_literal (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "failed to dump ICC file to temp file");
+ goto out;
+ }
+ ret = g_file_get_contents (temp_file, &data_tmp, &length, NULL);
+ if (!ret) {
+ g_set_error_literal (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "failed to load temp file");
+ goto out;
+ }
+ g_unlink (temp_file);
+#endif
/* success */
data = g_bytes_new (data_tmp, length);