diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2016-06-08 09:16:29 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2016-06-08 09:16:29 +0000 |
| commit | 5401a129da2f319316221727fef5c516c3a72906 (patch) | |
| tree | a3ffe6d401049f13799590159ea3a3e837e19b8b | |
| parent | Really remove last of svg_units. (diff) | |
| download | inkscape-5401a129da2f319316221727fef5c516c3a72906.tar.gz inkscape-5401a129da2f319316221727fef5c516c3a72906.zip | |
Only update inkscape.version on successful file write.
(bzr r14965)
| -rw-r--r-- | src/document.cpp | 5 | ||||
| -rw-r--r-- | src/file.cpp | 16 | ||||
| -rw-r--r-- | src/sp-root.cpp | 8 |
3 files changed, 20 insertions, 9 deletions
diff --git a/src/document.cpp b/src/document.cpp index e9388893e..d8c3f1269 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -369,11 +369,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, // Recursively build object tree document->root->invoke_build(document, rroot, false); - /* fixme: Not sure about this, but lets assume ::build updates */ - rroot->setAttribute("inkscape:version", Inkscape::version_string); - /* fixme: Again, I moved these here to allow version determining in ::build (Lauris) */ - - /* Eliminate obsolete sodipodi:docbase, for privacy reasons */ rroot->setAttribute("sodipodi:docbase", NULL); diff --git a/src/file.cpp b/src/file.cpp index 9d390908e..650ce5d0f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -45,7 +45,7 @@ #include "helper/png-write.h" #include "id-clash.h" #include "inkscape.h" -#include "inkscape.h" +#include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" #include "message.h" @@ -318,6 +318,12 @@ bool sp_file_open(const Glib::ustring &uri, // everyone who cares now has a reference, get rid of our`s doc->doUnref(); + SPRoot *root = doc->getRoot(); + + // This is the only place original values should be set. + root->original.inkscape = root->version.inkscape; + root->original.svg = root->version.svg; + // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); @@ -669,6 +675,8 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, if (!doc || uri.size()<1) //Safety check return false; + Inkscape::Version save = doc->getRoot()->version.inkscape; + doc->getReprRoot()->setAttribute("inkscape:version", Inkscape::version_string); try { Inkscape::Extension::save(key, doc, uri.c_str(), false, @@ -681,6 +689,8 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + // Restore Inkscape version + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::file_read_only &e) { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); @@ -689,6 +699,7 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::save_failed &e) { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); @@ -697,14 +708,17 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::save_cancelled &e) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::no_overwrite &e) { return sp_file_save_dialog(parentWindow, doc, save_method); } catch (...) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 8bedec0a5..98eae2159 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -313,9 +313,11 @@ Inkscape::XML::Node *SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::X repr = xml_doc->createElement("svg:svg"); } - if (flags & SP_OBJECT_WRITE_EXT) { - repr->setAttribute("inkscape:version", Inkscape::version_string); - } + /* Only update version string on successful write to file. This is handled by 'file_save()'. + * if (flags & SP_OBJECT_WRITE_EXT) { + * repr->setAttribute("inkscape:version", Inkscape::version_string); + * } + */ if (!repr->attribute("version")) { gchar *myversion = sp_version_to_string(this->version.svg); |
