diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/module/ModuleLoader.hpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/module/ModuleLoader.hpp b/include/module/ModuleLoader.hpp index 02b368e..9626972 100755 --- a/include/module/ModuleLoader.hpp +++ b/include/module/ModuleLoader.hpp @@ -83,26 +83,28 @@ class BaseModuleLoader { if( m.registry->initModule != 0 ) { m.registry->initModule( ); } - + m_modules.insert( std::make_pair( m.registry->name, m ) ); } } virtual ~BaseModuleLoader< Interface, CtorParams >( ) { - for( typename mapType::iterator it = m_modules.begin( ); it != m_modules.end( ); it++ ) { - if( (*it).second.handle ) { - if( (*it).second.registry->destroyModule != 0 ) { - (*it).second.registry->destroyModule( ); - } - + // KLUDGE: we (ab)use the list of modules to remember the destructors + // of derived classes to be called, This should be changed.. + // So we inspect only the being of the module list here. + typename mapType::iterator it = m_modules.begin( ); + if( (*it).second.registry ) { + if( (*it).second.registry->destroyModule != 0 ) { + (*it).second.registry->destroyModule( ); + } + } + if( (*it).second.handle ) { #ifndef _WIN32 - dlclose( (*it).second.handle ); + dlclose( (*it).second.handle ); #else - (void)FreeLibrary( (*it).second.handle ); + (void)FreeLibrary( (*it).second.handle ); #endif - (*it).second.handle = 0; - } } } |