From: caremoli Date: Tue, 7 Sep 2010 13:07:02 +0000 (+0000) Subject: CCAR: fix a bug in KeepOnlyResourcesWithComponent (erase an item of a vector when... X-Git-Tag: V5_1_5a1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f3f023c8786af9daded24c45049c0844f1407812;p=modules%2Fkernel.git CCAR: fix a bug in KeepOnlyResourcesWithComponent (erase an item of a vector when looping on it) and allow GiveContainer to raise SALOME exceptions to catch them in YACS --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index ed5c9796e..88385755b 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -216,7 +216,7 @@ interface ContainerManager //! GiveContainer - use mode parameter of ContainerParameters to configure //! how this method works //! Currently: get, start, getorstart, findorstart, find - Container GiveContainer(in ContainerParameters params); + Container GiveContainer(in ContainerParameters params) raises (SALOME::SALOME_Exception); //! Shutdown all containers that have been launched by the container manager void ShutdownContainers(); diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index a265e9f25..868ac8cb8 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -455,21 +455,21 @@ void ResourcesManager_cpp::KeepOnlyResourcesWithComponent(std::vector& resources, const std::vector& componentList) { + std::vector kept_resources; + std::vector::iterator iter = resources.begin(); for (; iter != resources.end(); iter++) { - MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); - const std::vector& mapOfComponentsOfCurrentHost = (*it).second.ComponentsList; + const std::vector& mapOfComponentsOfCurrentHost = _resourcesList[*iter].ComponentsList; bool erasedHost = false; if( mapOfComponentsOfCurrentHost.size() > 0 ) { for(unsigned int i=0; i::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(), - mapOfComponentsOfCurrentHost.end(), - compoi); + mapOfComponentsOfCurrentHost.end(), + componentList[i]); if (itt == mapOfComponentsOfCurrentHost.end()) { erasedHost = true; @@ -477,9 +477,10 @@ ResourcesManager_cpp::KeepOnlyResourcesWithComponent(std::vector& r } } } - if(erasedHost) - resources.erase(iter); + if(!erasedHost) + kept_resources.push_back(*iter); } + resources=kept_resources; }