diff --git a/brain/circuit.cpp b/brain/circuit.cpp index c437ac9..81a8745 100644 --- a/brain/circuit.cpp +++ b/brain/circuit.cpp @@ -103,37 +103,38 @@ URIs Circuit::getMorphologyURIs( const GIDSet& gids ) const } Morphologies Circuit::loadMorphologies( const GIDSet& gids, - Coordinates coords ) const + const Coordinates coords ) const { - // Creating all the brion::Morphologies objects first to detect a missing - // morphology before loading anything. const URIs& uris = getMorphologyURIs( gids ); - std::vector< boost::shared_ptr< brion::Morphology > > raw; - raw.reserve( uris.size( )); - BOOST_FOREACH( const URI& uri, uris ) - raw.push_back( boost::shared_ptr< brion::Morphology >( - new brion::Morphology( uri.getPath( )))); - Morphologies result; - result.reserve( gids.size( )); + result.reserve( uris.size( )); if( coords == COORDINATES_GLOBAL ) { const Matrix4fs& transforms = getTransforms( gids ); - for( size_t i = 0; i != uris.size(); ++i ) - result.push_back( - MorphologyPtr( new Morphology( *raw[i], transforms[i] ))); + for( size_t i = 0; i < uris.size(); ++i ) + { + const URI& uri = uris[i]; + const brion::Morphology raw( uri.getPath( )); + result.push_back( MorphologyPtr( new Morphology( raw, + transforms[i] ))); + } + return result; } - else + + std::map< std::string, MorphologyPtr > loaded; + for( size_t i = 0; i < uris.size(); ++i ) { - std::map< std::string, MorphologyPtr > loaded; - for( size_t i = 0; i != uris.size(); ++i ) + const URI& uri = uris[i]; + + MorphologyPtr& morphology = loaded[uri.getPath()]; + if( !morphology ) { - MorphologyPtr& morphology = loaded[uris[i].getPath()]; - if( !morphology ) - morphology.reset( new Morphology( *raw[i] )); - result.push_back( morphology ); + const brion::Morphology raw( uri.getPath( )); + morphology.reset( new Morphology( raw )); } + + result.push_back( morphology ); } return result; } diff --git a/doc/Changelog.md b/doc/Changelog.md index c876e61..d47a1dd 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -3,6 +3,8 @@ Changelog {#Changelog} # git master +* [38](https://github.com/BlueBrain/Brion/pull/38): + Fix crash while reading more than `ulimit -Sn` (1024 default) morphologies * [31](https://github.com/BlueBrain/Brion/pull/31): Fix crash while reading more than `ulimit -Sn` (1024 default) NEST gdf files * [30](https://github.com/BlueBrain/Brion/pull/30):