Commit 84c8dc21 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] - fixed uncatched exception if multiple modules with same module name...

[FIX] - fixed uncatched exception if multiple modules with same module name where loaded. Now they get ignored and no exception is thrown anymore.
parent df2732b9
...@@ -58,33 +58,34 @@ void WModuleFactory::load() ...@@ -58,33 +58,34 @@ void WModuleFactory::load()
WLogger::getLogger()->addLogMessage( "Loading Modules", "ModuleFactory", LL_INFO ); WLogger::getLogger()->addLogMessage( "Loading Modules", "ModuleFactory", LL_INFO );
// operation must be exclusive // operation must be exclusive
PrototypeSharedContainerType::WriteTicket m_prototypeAccess = m_prototypes.getWriteTicket(); PrototypeSharedContainerType::WriteTicket l = m_prototypes.getWriteTicket();
// Load the dynamic modules here: // Load the dynamic modules here:
m_moduleLoader.load( m_prototypeAccess ); m_moduleLoader.load( l );
// unlock as read lock is sufficient for the further steps
m_prototypeAccess.reset();
// for this a read lock is sufficient, gets unlocked if it looses scope
PrototypeSharedContainerType::ReadTicket l = m_prototypes.getReadTicket();
// initialize every module in the set // initialize every module in the set
std::set< std::string > names; // helper to find duplicates std::set< std::string > names; // helper to find duplicates
for( PrototypeContainerConstIteratorType listIter = l->get().begin(); listIter != l->get().end(); PrototypeContainerIteratorType listIter = l->get().begin();
++listIter ) while( listIter != l->get().end() )
{ {
WLogger::getLogger()->addLogMessage( "Initializing module prototype: \"" + ( *listIter )->getName() + "\"", "ModuleFactory", LL_DEBUG ); WLogger::getLogger()->addLogMessage( "Initializing module prototype: \"" + ( *listIter )->getName() + "\"", "ModuleFactory", LL_DEBUG );
// that should not happen. Names should not occur multiple times since they are unique // that should not happen. Names should not occur multiple times since they are unique
if( names.count( ( *listIter )->getName() ) ) if( names.count( ( *listIter )->getName() ) )
{ {
throw WPrototypeNotUnique( std::string( "Module \"" + ( *listIter )->getName() WLogger::getLogger()->addLogMessage( std::string( "Module \"" + ( *listIter )->getName() +
+ "\" is not unique. Modules have to have a unique name." ) ); "\" is not unique. Modules have to have a unique name. Ignoring this module." ),
"ModuleFactory", LL_ERROR );
// we remove the module from the prototype list
l->get().erase( listIter++ );
continue;
}
else
{
names.insert( ( *listIter )->getName() );
initializeModule( ( *listIter ) );
++listIter;
} }
names.insert( ( *listIter )->getName() );
initializeModule( ( *listIter ) );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment