diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index ba2488765a..65fbca44cb 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 9618f5c96f..2662adf428 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")