diff --git a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp index 79bff7b89c77..64c7084fdff3 100644 --- a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp @@ -28,11 +28,12 @@ FileBackedExperimentInfo::FileBackedExperimentInfo(const std::string &filename, : ExperimentInfo(), m_loaded(false), m_filename(filename), m_nxpath(nxpath) {} /** - * @return A clone of the object + * This clones the FileBackedExperimentInfo and will not cause a load + * of the information. + * @return A clone of the object. */ ExperimentInfo *FileBackedExperimentInfo::cloneExperimentInfo() const { - populateIfNotLoaded(); - return ExperimentInfo::cloneExperimentInfo(); + return new FileBackedExperimentInfo(*this); } /// @returns A human-readable description of the object diff --git a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h index b7ec12deea26..f3fa9eb6c621 100644 --- a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h +++ b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h @@ -45,12 +45,12 @@ class FileBackedExperimentInfoTest : public CxxTest::TestSuite { TS_ASSERT_EQUALS(fileBacked->toString(), m_inMemoryExptInfo->toString()); } - void test_cloneExperimentInfo_populates_object() { + void test_cloneExperimentInfo_returns_new_file_backed_object_and_does_not_touch_file() { auto fileBacked = createTestObject(); auto *clonedFileBacked = fileBacked->cloneExperimentInfo(); - TS_ASSERT_EQUALS(clonedFileBacked->toString(), - m_inMemoryExptInfo->toString()); + TS_ASSERT(dynamic_cast(clonedFileBacked)); + delete clonedFileBacked; }