[gnome-color-manager] Do not use a predictable name when saving the PLY temp file
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Do not use a predictable name when saving the PLY temp file
- Date: Tue, 30 Jul 2013 09:10:08 +0000 (UTC)
commit 42ae05a8914f8f1adc52e5296b281f0bc5080718
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 30 09:36:53 2013 +0100
Do not use a predictable name when saving the PLY temp file
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=958088
src/gcm-hull-widget.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/gcm-hull-widget.c b/src/gcm-hull-widget.c
index a5f6b50..c56fd01 100644
--- a/src/gcm-hull-widget.c
+++ b/src/gcm-hull-widget.c
@@ -97,15 +97,24 @@ gcm_hull_widget_add (GcmHullWidget *hull_widget,
gchar *ply_data = NULL;
GcmHull *hull = NULL;
GError *error = NULL;
+ gchar *temp_file = NULL;
+ gint fd = -1;
/* generate hull */
hull = cd_icc_generate_gamut_hull (profile, 12);
if (hull == NULL)
goto out;
+ fd = g_file_open_tmp ("gnome-color-manager-XXXXXX.icc", &temp_file, &error);
+ if (fd < 0) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
/* save as PLY file */
ply_data = gcm_hull_export_to_ply (hull);
- ret = g_file_set_contents ("/tmp/gamut.ply", ply_data, -1, &error);
+ ret = g_file_set_contents (temp_file, ply_data, -1, &error);
if (!ret) {
g_warning ("%s", error->message);
g_error_free (error);
@@ -113,7 +122,7 @@ gcm_hull_widget_add (GcmHullWidget *hull_widget,
}
/* load model: TODO: use mash_model_new_from_data() */
- model = mash_model_new_from_file (MASH_DATA_NONE, "/tmp/gamut.ply",
+ model = mash_model_new_from_file (MASH_DATA_NONE, temp_file,
&error);
if (model == NULL) {
g_warning ("%s", error->message);
@@ -149,6 +158,11 @@ gcm_hull_widget_add (GcmHullWidget *hull_widget,
clutter_actor_show (model);
ret = TRUE;
out:
+ if (fd >= 0)
+ close (fd);
+ if (temp_file != NULL)
+ g_unlink (temp_file);
+ g_free (temp_file);
g_free (ply_data);
if (hull != NULL)
g_object_unref (hull);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]