[goffice] Fix saving color maps when directory does not exists. [#735008]



commit 8fa975db808aabc538c0303e8f5d865483d28a10
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Aug 18 21:35:12 2014 +0200

    Fix saving color maps when directory does not exists. [#735008]

 ChangeLog                          |    5 +++++
 NEWS                               |    1 +
 goffice/graph/gog-axis-color-map.c |   14 +++++++++++++-
 3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 77b6009..bf9d5bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-18  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-axis-color-map.c (gog_axis_color_map_save): create
+       $HOME/.goffice/colormaps if needed. [#735008]
+
 2014-08-10  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/utils/go-style.c (cb_pattern_type_activate),
diff --git a/NEWS b/NEWS
index 45837d0..6a62ffc 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Jean:
        * Fix grid line theme support. [#733403]
        * Fix default ticks position.
        * Fix font color theme support. [Debian 757611]
+       * Fix saving color maps when directory does not exists. [#735008]
 
 Morten:
        * Work around gtk+ ABI break for colour selector.  [#733350]
diff --git a/goffice/graph/gog-axis-color-map.c b/goffice/graph/gog-axis-color-map.c
index 3855723..8c0ac69 100644
--- a/goffice/graph/gog-axis-color-map.c
+++ b/goffice/graph/gog-axis-color-map.c
@@ -32,6 +32,7 @@
 #ifdef GOFFICE_WITH_GTK
 #include <gtk/gtk.h>
 #endif
+#include <sys/stat.h>
 
 /**
  * SECTION: gog-axis-color-map
@@ -303,7 +304,18 @@ static void
 gog_axis_color_map_save (GogAxisColorMap const *map)
 {
        GsfOutput *output = gsf_output_gio_new_for_uri (map->uri, NULL);
-       GsfXMLOut *xml = gsf_xml_out_new (output);
+       GsfXMLOut *xml;
+       if (output == NULL) {
+               char *dir = go_dirname_from_uri (map->uri, TRUE);
+               int res = g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | 
S_IROTH | S_IXOTH);
+               g_free (dir);
+               if (res < 0) {
+                       g_warning ("[GogAxisColorMap]: Could not save color map to %s", map->uri);
+                       return;
+               }
+               output = gsf_output_gio_new_for_uri (map->uri, NULL);
+       }
+       xml = gsf_xml_out_new (output);
        gsf_xml_out_start_element (xml, "GogAxisColorMap");
        gog_axis_color_map_write (GO_PERSIST (map), xml);
        gsf_xml_out_end_element (xml);


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