From 17dcb846828bb2e07abe8547d524391b646ae98d Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 6 May 2013 11:28:13 +0200 Subject: [PATCH] Rename transient directory when saving document under new file --- src/App/Document.cpp | 7 +++++-- src/App/PropertyFile.cpp | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 6af947de50..fb9f28a377 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -459,8 +459,10 @@ void Document::onChanged(const Property* prop) this->TransientDir.setValue(new_dir); } } - // make sure that the uuid is unique - else { + // when reloading an existing document the transient directory doesn't change + // so we must avoid to generate a new uuid + else if (TransDirNew.filePath() != TransDirOld.filePath()) { + // make sure that the uuid is unique std::string uuid = this->Uid.getValueStr(); Base::Uuid id; Base::Console().Warning("Document with the UUID '%s' already exists, change to '%s'\n", @@ -894,6 +896,7 @@ bool Document::saveAs(const char* file) if (this->FileName.getStrValue() != file) { this->FileName.setValue(file); this->Label.setValue(fi.fileNamePure()); + this->Uid.touch(); // this forces a rename of the transient directory } return save(); diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 77f5953ba1..ba2488765a 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -281,7 +281,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) void PropertyFileIncluded::Save (Base::Writer &writer) const { -#if 0 // when saving a document under a new file name the transient directory // name changes and thus the stored file name doesn't work any more. if (!_cValue.empty() && !Base::FileInfo(_cValue).exists()) { @@ -289,7 +288,7 @@ void PropertyFileIncluded::Save (Base::Writer &writer) const if (fi.exists()) _cValue = fi.filePath(); } -#endif + if (writer.isForceXML()) { if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str());