@ -300,22 +300,12 @@ ModuleManager::loadModules()
continue ;
}
if ( ! checkModuleDependencies( * thisModule ) )
if ( ! addModule( thisModule ) )
{
// Error message is already printed
failedModules . append ( instanceKey . toString ( ) ) ;
continue ;
}
// If it's a ViewModule, it also appends the ViewStep to the ViewManager.
thisModule - > loadSelf ( ) ;
m_loadedModulesByInstanceKey . insert ( instanceKey , thisModule ) ;
if ( ! thisModule - > isLoaded ( ) )
{
cError ( ) < < " Module " < < instanceKey . toString ( ) < < " loading FAILED. " ;
failedModules . append ( instanceKey . toString ( ) ) ;
continue ;
}
}
// At this point we most certainly have a pointer to a loaded module in
@ -345,6 +335,40 @@ ModuleManager::loadModules()
}
}
bool
ModuleManager : : addModule ( Module * module )
{
if ( ! module )
{
return false ;
}
if ( ! module - > instanceKey ( ) . isValid ( ) )
{
cWarning ( ) < < " Module " < < module - > location ( ) < < ' @ ' < < ( void * ) module < < " has invalid instance key. " ;
return false ;
}
if ( ! checkModuleDependencies ( * module ) )
{
return false ;
}
if ( ! module - > isLoaded ( ) )
{
module - > loadSelf ( ) ;
}
// Even if the load failed, we keep the module, so that if it tried to
// get loaded **again**, we already know.
m_loadedModulesByInstanceKey . insert ( module - > instanceKey ( ) , module ) ;
if ( ! module - > isLoaded ( ) )
{
cError ( ) < < " Module " < < module - > instanceKey ( ) . toString ( ) < < " loading FAILED. " ;
return false ;
}
return true ;
}
void
ModuleManager : : checkRequirements ( )
{
@ -414,6 +438,12 @@ ModuleManager::checkDependencies()
bool
ModuleManager : : checkModuleDependencies ( const Module & m )
{
if ( ! m_availableDescriptorsByModuleName . contains ( m . name ( ) ) )
{
cWarning ( ) < < " Module " < < m . name ( ) < < " loaded externally, no dependency information. " ;
return true ;
}
bool allRequirementsFound = true ;
QStringList requiredModules
= m_availableDescriptorsByModuleName [ m . name ( ) ] . value ( " requiredModules " ) . toStringList ( ) ;