summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-10-04 22:27:45 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2014-10-04 22:27:45 +0200
commit8f97e74456a2698d59471682c63929b1af124230 (patch)
tree2fa2cab96617e0b6dc6ce835939a07a5000f3cdc /include
parent578f8d8b0bec9ba3e5a1f8b4bf26b66f58dd6752 (diff)
downloadcrawler-8f97e74456a2698d59471682c63929b1af124230.tar.gz
crawler-8f97e74456a2698d59471682c63929b1af124230.tar.bz2
fixed code in destructor of BaseModuleLoader, was a little bit weird
Diffstat (limited to 'include')
-rwxr-xr-xinclude/module/ModuleLoader.hpp24
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;
- }
}
}