diff --git a/hurricane/src/hurricane/Entity.cpp b/hurricane/src/hurricane/Entity.cpp index e679f752..9accc0db 100644 --- a/hurricane/src/hurricane/Entity.cpp +++ b/hurricane/src/hurricane/Entity.cpp @@ -115,7 +115,6 @@ namespace Hurricane { for(; it != end ; it++) slaveEntities.push_back(it->second); for(; slaveEntities.size() ; slaveEntities.pop_back()) { - cerr << "Erasing " << slaveEntities.back() << endl; slaveEntities.back()->destroy(); } diff --git a/hurricane/src/hurricane/Instance.cpp b/hurricane/src/hurricane/Instance.cpp index 14a7283e..67067f51 100644 --- a/hurricane/src/hurricane/Instance.cpp +++ b/hurricane/src/hurricane/Instance.cpp @@ -579,16 +579,17 @@ void Instance::_postCreate() void Instance::_preDestroy() // ************************ { - for_each_shared_path(sharedPath, _getSharedPathes()) delete sharedPath; end_for; + for ( SharedPath* sharedPath : _getSharedPathes() ) delete sharedPath; - Inherit::_preDestroy(); + Inherit::_preDestroy(); - for_each_plug(plug, getPlugs()) plug->_destroy(); end_for; + Plugs plugs = getPlugs(); + while ( plugs.getFirst() ) plugs.getFirst()->_destroy(); - _masterCell->_getSlaveInstanceSet()._remove(this); - _cell->_getInstanceMap()._remove(this); + _masterCell->_getSlaveInstanceSet()._remove(this); + _cell->_getInstanceMap()._remove(this); - if (_masterCell->isUniquified()) _masterCell->destroy(); + if (_masterCell->isUniquified()) _masterCell->destroy(); } string Instance::_getString() const diff --git a/hurricane/src/hurricane/Library.cpp b/hurricane/src/hurricane/Library.cpp index 6fcd9dcd..e7716929 100644 --- a/hurricane/src/hurricane/Library.cpp +++ b/hurricane/src/hurricane/Library.cpp @@ -126,13 +126,11 @@ void Library::_preDestroy() { Inherit::_preDestroy(); - for_each_cell(cell, getCells()) cell->destroy(); end_for; - for_each_library(library, getLibraries()) library->destroy(); end_for; + Cells cells = getCells (); while (cells .getFirst()) cells .getFirst()->destroy(); + Libraries libraries = getLibraries(); while (libraries.getFirst()) libraries.getFirst()->destroy(); - if (!_library) - _dataBase->_setRootLibrary(NULL); - else - _library->_getLibraryMap()._remove(this); + if (not _library) _dataBase->_setRootLibrary( NULL ); + else _library->_getLibraryMap()._remove( this ); } string Library::_getString() const diff --git a/hurricane/src/hurricane/Net.cpp b/hurricane/src/hurricane/Net.cpp index 8411571c..796ef531 100644 --- a/hurricane/src/hurricane/Net.cpp +++ b/hurricane/src/hurricane/Net.cpp @@ -681,11 +681,13 @@ void Net::_preDestroy() { Inherit::_preDestroy(); - for_each_plug(slavePlug, getSlavePlugs()) slavePlug->_destroy(); end_for; + Plugs plugs = getSlavePlugs(); + while ( plugs.getFirst() ) plugs.getFirst()->_destroy(); unmaterialize(); - for_each_rubber(rubber, getRubbers()) rubber->_destroy(); end_for; + Rubbers rubbers = getRubbers(); + while ( rubbers.getFirst() ) rubbers.getFirst()->_destroy(); for_each_component(component, getComponents()) { for_each_hook(hook, component->getHooks()) { @@ -694,16 +696,17 @@ void Net::_preDestroy() //if (!hook->IsMaster()) hook->detach(); hook->detach(); end_for; + // 24/02/2016 jpc: the answer, at last... we cannot iterate + // over a collection as it is modificated/destroyed! } end_for; } - for_each_component(component, getComponents()) { - if (!dynamic_cast(component)) - component->destroy(); - else - ((Plug*)component)->setNet(NULL); - end_for; + Components components = getComponents(); + while ( components.getFirst() ) { + Component* component = components.getFirst(); + if (!dynamic_cast(component)) component->destroy(); + else (static_cast(component))->setNet(NULL); } _mainName.clear(); diff --git a/hurricane/src/hurricane/Technology.cpp b/hurricane/src/hurricane/Technology.cpp index ff8cb56e..2068b4f2 100644 --- a/hurricane/src/hurricane/Technology.cpp +++ b/hurricane/src/hurricane/Technology.cpp @@ -351,10 +351,9 @@ void Technology::_preDestroy() // ************************** { - while ( !_layerMap.isEmpty() ) { + while ( not _layerMap.isEmpty() ) { _layerMap.getElements().getFirst()->destroy(); } - //for_each_layer(layer, getLayers()) layer->destroy(); end_for; _dataBase->_setTechnology(NULL); DBo::_preDestroy();