From 50559c4b173a96dd87370202135c070d4399c1fe Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 6 May 2013 12:27:25 +0200 Subject: [PATCH] One more fix to avoid loss of data --- src/App/PropertyFile.cpp | 10 +++++++++- src/Mod/Test/Document.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index ba2488765..65fbca44c 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -153,6 +153,12 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName) _BaseFileName = file.fileName(); } + // That's wrong and can lead to loss of data!!! + // Just consider the example that two objects with this property + // exist in the same document and as an initial step the data are + // copied from one object to the other. A rename will cause the one + // object to loose its data. +#if 0 // if the file is already in transient dir of the document, just use it if (path == pathTrans) { bool done = file.renameFile(_cValue.c_str()); @@ -163,7 +169,9 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName) } } // otherwise copy from origin location - else { + else +#endif + { // if file already exists in transient dir make a new unique name Base::FileInfo fi(_cValue); if (fi.exists()) { diff --git a/src/Mod/Test/Document.py b/src/Mod/Test/Document.py index 9618f5c96..2662adf42 100644 --- a/src/Mod/Test/Document.py +++ b/src/Mod/Test/Document.py @@ -728,6 +728,10 @@ class DocumentFileIncludeCases(unittest.TestCase): self.failUnless(os.path.exists(L5.File)) self.failUnless(os.path.exists(L6.File)) self.failUnless(L5.File != L6.File) + # copy file from L5 which is in the same directory + L7 = doc2.addObject("App::DocumentObjectFileIncluded","FileObject3") + L7.File = (L5.File,"Copy.txt") + self.failUnless(os.path.exists(L5.File)) FreeCAD.closeDocument("Doc2")