From 6aa2d9958767a3eb31e22fe29527f97b2427c990 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 11:00:46 +0100 Subject: [PATCH] #2349 Elm Props: Only add files which are not already added --- .../ProjectDataModel/RimGeoMechCase.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index ec6c3a141f..89ff2bc2fd 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -332,16 +332,32 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) { - for (const QString& fileName : fileNames) + std::vector newFileNames; + + for (const QString& newFileNameToPossiblyAdd : fileNames) { - m_elementPropertyFileNames.v().push_back(fileName); + bool fileAlreadyAdded = false; + + for (const QString& existingFileName : m_elementPropertyFileNames.v()) + { + if (existingFileName == newFileNameToPossiblyAdd) + { + fileAlreadyAdded = true; + break; + } + } + if (!fileAlreadyAdded) + { + newFileNames.push_back(newFileNameToPossiblyAdd); + m_elementPropertyFileNames.v().push_back(newFileNameToPossiblyAdd); + } } this->updateConnectedEditors(); if (m_geoMechCaseData.notNull()) { - geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); + geoMechData()->femPartResults()->addElementPropertyFiles(newFileNames); } }