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++)
slaveEntities.push_back(it->second);
for(; slaveEntities.size() ; slaveEntities.pop_back()) {
cerr << "Erasing " << slaveEntities.back() << endl;
slaveEntities.back()->destroy();
}

View File

@ -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

View File

@ -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

View File

@ -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<Plug*>(component))
component->destroy();
else
((Plug*)component)->setNet(NULL);
end_for;
Components components = getComponents();
while ( components.getFirst() ) {
Component* component = components.getFirst();
if (!dynamic_cast<Plug*>(component)) component->destroy();
else (static_cast<Plug*>(component))->setNet(NULL);
}
_mainName.clear();

View File

@ -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();