diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-02-04 16:04:38 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-02-04 16:04:38 +0000 |
| commit | d9850e5bf76be9357454a35dbd8c85a6d14df5ff (patch) | |
| tree | 85410afa033bbf58ffbbba50e6d525bedaf5f0ca /src | |
| parent | Unions Are Evil! When pixblock size is TINY, it stores data right in the data... (diff) | |
| download | inkscape-d9850e5bf76be9357454a35dbd8c85a6d14df5ff.tar.gz inkscape-d9850e5bf76be9357454a35dbd8c85a6d14df5ff.zip | |
Fixed saving bug, now attributes are correctly handled for both normal saves and 'save-a-copy' saves.
(bzr r2326)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/system.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/extension/system.cpp b/src/extension/system.cpp index c653cc438..3eb9cf809 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -6,9 +6,10 @@ * * Authors: * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * - * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> - * Copyright (C) 2002-2004 Authors + * Copyright (C) 2006-2007 Johan Engelen + * Copyright (C) 2002-2004 Ted Gould * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -245,35 +246,61 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, throw Output::no_overwrite(); } - if (official) { - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive (doc, false); - Inkscape::XML::Node *repr = sp_document_repr_root(doc); - repr->setAttribute("sodipodi:modified", NULL); - sp_document_set_undo_sensitive (doc, saved); - } + Inkscape::XML::Node *repr = sp_document_repr_root(doc); - omod->save(doc, fileName); + // remember attributes in case this is an unofficial save + gchar *saved_sodipodi_modified = NULL; + gchar *saved_output_extension = NULL; + gchar *saved_dataloss = NULL; + gchar *saved_uri = NULL; + if (!official) { + if (repr->attribute("sodipodi:modified")) { + saved_sodipodi_modified = g_strdup(repr->attribute("sodipodi:modified")); + } + if (repr->attribute("inkscape:output_extension")) { + saved_output_extension = g_strdup(repr->attribute("inkscape:output_extension")); + } + if (repr->attribute("inkscape:dataloss")) { + saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss")); + } + if (doc->uri) { + saved_uri = g_strdup(doc->uri); + } + } - if (official) { + // update attributes: + bool saved = sp_document_get_undo_sensitive(doc); + sp_document_set_undo_sensitive (doc, false); + repr->setAttribute("sodipodi:modified", NULL); // save the filename for next use sp_document_set_uri(doc, fileName); - - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive (doc, false); - // also save the extension for next use - Inkscape::XML::Node *repr = sp_document_repr_root(doc); repr->setAttribute("inkscape:output_extension", omod->get_id()); // set the "dataloss" attribute if the chosen extension is lossy repr->setAttribute("inkscape:dataloss", NULL); if ( omod->causes_dataloss() ) { repr->setAttribute("inkscape:dataloss", "true"); } + sp_document_set_undo_sensitive (doc, saved); + omod->save(doc, fileName); + + // if it is an unofficial save, set the modified attributes back to what they were + if ( !official) { + saved = sp_document_get_undo_sensitive(doc); + sp_document_set_undo_sensitive (doc, false); + repr->setAttribute("sodipodi:modified", saved_sodipodi_modified); + repr->setAttribute("inkscape:output_extension", saved_output_extension); + repr->setAttribute("inkscape:dataloss", saved_dataloss); + sp_document_set_uri(doc, saved_uri); sp_document_set_undo_sensitive (doc, saved); } + if (saved_sodipodi_modified) g_free(saved_sodipodi_modified); + if (saved_output_extension) g_free(saved_output_extension); + if (saved_dataloss) g_free(saved_dataloss); + if (saved_uri) g_free(saved_uri); + g_free(fileName); return; } |
