diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h index b388acb0ac34ec9cd1837a2ddc6869ab42551e08..bda9f966a7c6c711f6e88f30fb39ae98c5adb08e 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h @@ -252,7 +252,8 @@ namespace Mantid void cacheUserSearchPaths(); /// Returns true if the path is in the data search list bool isInDataSearchList(const std::string & path) const; - + /// Empty the list of facilities, deleting the FacilityInfo objects in the process + void clearFacilities(); /// Set the PV_PLUGIN_PATH to point at this version of Mantid. void setParaViewPluginPath() const; diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 9d8571e88156dc4069b8532a8be1153992cbb48e..f12e516c9ca60e8c89d4f137be914f6fc5e1131b 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -281,11 +281,7 @@ ConfigServiceImpl::~ConfigServiceImpl() Kernel::Logger::shutdown(); delete m_pSysConfig; delete m_pConf; // potential double delete??? - for (std::vector<FacilityInfo*>::iterator it = m_facilities.begin(); it != m_facilities.end(); ++it) - { - delete *it; - } - m_facilities.clear(); + clearFacilities(); } /** Loads the config file provided. @@ -1479,7 +1475,7 @@ const std::string ConfigServiceImpl::getInstrumentDirectory() const */ void ConfigServiceImpl::updateFacilities(const std::string& fName) { - m_facilities.clear(); + clearFacilities(); std::string instrDir = getString("instrumentDefinition.directory"); std::string fileName = fName.empty() ? instrDir + "Facilities.xml" : fName; @@ -1533,6 +1529,16 @@ void ConfigServiceImpl::updateFacilities(const std::string& fName) } +/// Empty the list of facilities, deleting the FacilityInfo objects in the process +void ConfigServiceImpl::clearFacilities() +{ + for (auto it = m_facilities.begin(); it != m_facilities.end(); ++it) + { + delete *it; + } + m_facilities.clear(); +} + /** * Returns instruments with given name * @param instrumentName Instrument name