More destructives iterations over collections correcteds.

* Bug: In Hurricane, in Entity, Instance, Library, Net & Technology, there
    loop over collections while destroying their elements.
This commit is contained in:
Jean-Paul Chaput 2016-02-24 10:44:33 +01:00
parent b57c81dda8
commit cdacecd32b
5 changed files with 23 additions and 23 deletions

View File

@ -115,7 +115,6 @@ namespace Hurricane {
for(; it != end ; it++) for(; it != end ; it++)
slaveEntities.push_back(it->second); slaveEntities.push_back(it->second);
for(; slaveEntities.size() ; slaveEntities.pop_back()) { for(; slaveEntities.size() ; slaveEntities.pop_back()) {
cerr << "Erasing " << slaveEntities.back() << endl;
slaveEntities.back()->destroy(); slaveEntities.back()->destroy();
} }

View File

@ -579,11 +579,12 @@ void Instance::_postCreate()
void Instance::_preDestroy() 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); _masterCell->_getSlaveInstanceSet()._remove(this);
_cell->_getInstanceMap()._remove(this); _cell->_getInstanceMap()._remove(this);

View File

@ -126,13 +126,11 @@ void Library::_preDestroy()
{ {
Inherit::_preDestroy(); Inherit::_preDestroy();
for_each_cell(cell, getCells()) cell->destroy(); end_for; Cells cells = getCells (); while (cells .getFirst()) cells .getFirst()->destroy();
for_each_library(library, getLibraries()) library->destroy(); end_for; Libraries libraries = getLibraries(); while (libraries.getFirst()) libraries.getFirst()->destroy();
if (!_library) if (not _library) _dataBase->_setRootLibrary( NULL );
_dataBase->_setRootLibrary(NULL); else _library->_getLibraryMap()._remove( this );
else
_library->_getLibraryMap()._remove(this);
} }
string Library::_getString() const string Library::_getString() const

View File

@ -681,11 +681,13 @@ void Net::_preDestroy()
{ {
Inherit::_preDestroy(); Inherit::_preDestroy();
for_each_plug(slavePlug, getSlavePlugs()) slavePlug->_destroy(); end_for; Plugs plugs = getSlavePlugs();
while ( plugs.getFirst() ) plugs.getFirst()->_destroy();
unmaterialize(); 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_component(component, getComponents()) {
for_each_hook(hook, component->getHooks()) { for_each_hook(hook, component->getHooks()) {
@ -694,16 +696,17 @@ void Net::_preDestroy()
//if (!hook->IsMaster()) hook->detach(); //if (!hook->IsMaster()) hook->detach();
hook->detach(); hook->detach();
end_for; end_for;
// 24/02/2016 jpc: the answer, at last... we cannot iterate
// over a collection as it is modificated/destroyed!
} }
end_for; end_for;
} }
for_each_component(component, getComponents()) { Components components = getComponents();
if (!dynamic_cast<Plug*>(component)) while ( components.getFirst() ) {
component->destroy(); Component* component = components.getFirst();
else if (!dynamic_cast<Plug*>(component)) component->destroy();
((Plug*)component)->setNet(NULL); else (static_cast<Plug*>(component))->setNet(NULL);
end_for;
} }
_mainName.clear(); _mainName.clear();

View File

@ -351,10 +351,9 @@ void Technology::_preDestroy()
// ************************** // **************************
{ {
while ( !_layerMap.isEmpty() ) { while ( not _layerMap.isEmpty() ) {
_layerMap.getElements().getFirst()->destroy(); _layerMap.getElements().getFirst()->destroy();
} }
//for_each_layer(layer, getLayers()) layer->destroy(); end_for;
_dataBase->_setTechnology(NULL); _dataBase->_setTechnology(NULL);
DBo::_preDestroy(); DBo::_preDestroy();