[libcalamaresui] Replace a superfluous lambda
- The whole method body can be a lot on its own, and since loadModules() does nothing but single-shot the lambda, call it from outside instead.
This commit is contained in:
parent
ce6f6592d4
commit
d6ed046495
@ -39,6 +39,7 @@
|
|||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
CalamaresApplication::CalamaresApplication( int& argc, char* argv[] )
|
CalamaresApplication::CalamaresApplication( int& argc, char* argv[] )
|
||||||
@ -354,7 +355,7 @@ CalamaresApplication::initView()
|
|||||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps );
|
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps );
|
||||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, this, &CalamaresApplication::initFailed );
|
connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, this, &CalamaresApplication::initFailed );
|
||||||
|
|
||||||
m_moduleManager->loadModules();
|
QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules );
|
||||||
|
|
||||||
m_mainwindow->move( this->desktop()->availableGeometry().center() - m_mainwindow->rect().center() );
|
m_mainwindow->move( this->desktop()->availableGeometry().center() - m_mainwindow->rect().center() );
|
||||||
|
|
||||||
|
@ -182,133 +182,131 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co
|
|||||||
void
|
void
|
||||||
ModuleManager::loadModules()
|
ModuleManager::loadModules()
|
||||||
{
|
{
|
||||||
QTimer::singleShot( 0, this, [this]() {
|
QStringList failedModules = checkDependencies();
|
||||||
QStringList failedModules = checkDependencies();
|
Settings::InstanceDescriptionList customInstances = Settings::instance()->customModuleInstances();
|
||||||
Settings::InstanceDescriptionList customInstances = Settings::instance()->customModuleInstances();
|
|
||||||
|
|
||||||
const auto modulesSequence
|
const auto modulesSequence
|
||||||
= failedModules.isEmpty() ? Settings::instance()->modulesSequence() : Settings::ModuleSequence();
|
= failedModules.isEmpty() ? Settings::instance()->modulesSequence() : Settings::ModuleSequence();
|
||||||
for ( const auto& modulePhase : modulesSequence )
|
for ( const auto& modulePhase : modulesSequence )
|
||||||
|
{
|
||||||
|
ModuleSystem::Action currentAction = modulePhase.first;
|
||||||
|
|
||||||
|
foreach ( const QString& moduleEntry, modulePhase.second )
|
||||||
{
|
{
|
||||||
ModuleSystem::Action currentAction = modulePhase.first;
|
auto instanceKey = ModuleSystem::InstanceKey::fromString( moduleEntry );
|
||||||
|
if ( !instanceKey.isValid() )
|
||||||
foreach ( const QString& moduleEntry, modulePhase.second )
|
|
||||||
{
|
{
|
||||||
auto instanceKey = ModuleSystem::InstanceKey::fromString( moduleEntry );
|
cError() << "Wrong module entry format for module" << moduleEntry;
|
||||||
if ( !instanceKey.isValid() )
|
failedModules.append( moduleEntry );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( !m_availableDescriptorsByModuleName.contains( instanceKey.module() )
|
||||||
|
|| m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() )
|
||||||
|
{
|
||||||
|
cError() << "Module" << QString( instanceKey ) << "not found in module search paths."
|
||||||
|
<< Logger::DebugList( m_paths );
|
||||||
|
failedModules.append( QString( instanceKey ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString configFileName;
|
||||||
|
if ( instanceKey.isCustom() )
|
||||||
|
{
|
||||||
|
int found = findCustomInstance( customInstances, instanceKey );
|
||||||
|
|
||||||
|
if ( found > -1 )
|
||||||
{
|
{
|
||||||
cError() << "Wrong module entry format for module" << moduleEntry;
|
configFileName = customInstances[ found ].value( "config" );
|
||||||
|
}
|
||||||
|
else //ought to be a custom instance, but cannot find instance entry
|
||||||
|
{
|
||||||
|
cError() << "Custom instance" << moduleEntry << "not found in custom instances section.";
|
||||||
failedModules.append( moduleEntry );
|
failedModules.append( moduleEntry );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
configFileName = QString( "%1.conf" ).arg( instanceKey.module() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// So now we can assume that the module entry is at least valid,
|
||||||
|
// that we have a descriptor on hand (and therefore that the
|
||||||
|
// module exists), and that the instance is either default or
|
||||||
|
// defined in the custom instances section.
|
||||||
|
// We still don't know whether the config file for the entry
|
||||||
|
// exists and is valid, but that's the only thing that could fail
|
||||||
|
// from this point on. -- Teo 8/2015
|
||||||
|
Module* thisModule = m_loadedModulesByInstanceKey.value( instanceKey, nullptr );
|
||||||
|
if ( thisModule && !thisModule->isLoaded() )
|
||||||
|
{
|
||||||
|
cError() << "Module" << QString( instanceKey ) << "exists but not loaded.";
|
||||||
|
failedModules.append( QString( instanceKey ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_availableDescriptorsByModuleName.contains( instanceKey.module() )
|
if ( thisModule && thisModule->isLoaded() )
|
||||||
|| m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() )
|
{
|
||||||
|
cDebug() << "Module" << QString( instanceKey ) << "already loaded.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thisModule = Module::fromDescriptor( m_availableDescriptorsByModuleName.value( instanceKey.module() ),
|
||||||
|
instanceKey.id(),
|
||||||
|
configFileName,
|
||||||
|
m_moduleDirectoriesByModuleName.value( instanceKey.module() ) );
|
||||||
|
if ( !thisModule )
|
||||||
{
|
{
|
||||||
cError() << "Module" << QString( instanceKey ) << "not found in module search paths."
|
cError() << "Module" << QString( instanceKey ) << "cannot be created from descriptor" << configFileName;
|
||||||
<< Logger::DebugList( m_paths );
|
|
||||||
failedModules.append( QString( instanceKey ) );
|
failedModules.append( QString( instanceKey ) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString configFileName;
|
if ( !checkDependencies( *thisModule ) )
|
||||||
if ( instanceKey.isCustom() )
|
|
||||||
{
|
{
|
||||||
int found = findCustomInstance( customInstances, instanceKey );
|
// Error message is already printed
|
||||||
|
|
||||||
if ( found > -1 )
|
|
||||||
{
|
|
||||||
configFileName = customInstances[ found ].value( "config" );
|
|
||||||
}
|
|
||||||
else //ought to be a custom instance, but cannot find instance entry
|
|
||||||
{
|
|
||||||
cError() << "Custom instance" << moduleEntry << "not found in custom instances section.";
|
|
||||||
failedModules.append( moduleEntry );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
configFileName = QString( "%1.conf" ).arg( instanceKey.module() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// So now we can assume that the module entry is at least valid,
|
|
||||||
// that we have a descriptor on hand (and therefore that the
|
|
||||||
// module exists), and that the instance is either default or
|
|
||||||
// defined in the custom instances section.
|
|
||||||
// We still don't know whether the config file for the entry
|
|
||||||
// exists and is valid, but that's the only thing that could fail
|
|
||||||
// from this point on. -- Teo 8/2015
|
|
||||||
Module* thisModule = m_loadedModulesByInstanceKey.value( instanceKey, nullptr );
|
|
||||||
if ( thisModule && !thisModule->isLoaded() )
|
|
||||||
{
|
|
||||||
cError() << "Module" << QString( instanceKey ) << "exists but not loaded.";
|
|
||||||
failedModules.append( QString( instanceKey ) );
|
failedModules.append( QString( instanceKey ) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( thisModule && thisModule->isLoaded() )
|
// If it's a ViewModule, it also appends the ViewStep to the ViewManager.
|
||||||
|
thisModule->loadSelf();
|
||||||
|
m_loadedModulesByInstanceKey.insert( instanceKey, thisModule );
|
||||||
|
if ( !thisModule->isLoaded() )
|
||||||
{
|
{
|
||||||
cDebug() << "Module" << QString( instanceKey ) << "already loaded.";
|
cError() << "Module" << QString( instanceKey ) << "loading FAILED.";
|
||||||
}
|
failedModules.append( QString( instanceKey ) );
|
||||||
else
|
continue;
|
||||||
{
|
|
||||||
thisModule = Module::fromDescriptor( m_availableDescriptorsByModuleName.value( instanceKey.module() ),
|
|
||||||
instanceKey.id(),
|
|
||||||
configFileName,
|
|
||||||
m_moduleDirectoriesByModuleName.value( instanceKey.module() ) );
|
|
||||||
if ( !thisModule )
|
|
||||||
{
|
|
||||||
cError() << "Module" << QString( instanceKey ) << "cannot be created from descriptor" << configFileName;
|
|
||||||
failedModules.append( QString( instanceKey ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !checkDependencies( *thisModule ) )
|
|
||||||
{
|
|
||||||
// Error message is already printed
|
|
||||||
failedModules.append( QString( instanceKey ) );
|
|
||||||
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" << QString( instanceKey ) << "loading FAILED.";
|
|
||||||
failedModules.append( QString( instanceKey ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point we most certainly have a pointer to a loaded module in
|
|
||||||
// thisModule. We now need to enqueue jobs info into an EVS.
|
|
||||||
if ( currentAction == ModuleSystem::Action::Exec )
|
|
||||||
{
|
|
||||||
ExecutionViewStep* evs
|
|
||||||
= qobject_cast< ExecutionViewStep* >( Calamares::ViewManager::instance()->viewSteps().last() );
|
|
||||||
if ( !evs ) // If the last step is not an EVS, we must create it.
|
|
||||||
{
|
|
||||||
evs = new ExecutionViewStep( ViewManager::instance() );
|
|
||||||
ViewManager::instance()->addViewStep( evs );
|
|
||||||
}
|
|
||||||
|
|
||||||
evs->appendJobModuleInstanceKey( QString( instanceKey ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// At this point we most certainly have a pointer to a loaded module in
|
||||||
|
// thisModule. We now need to enqueue jobs info into an EVS.
|
||||||
|
if ( currentAction == ModuleSystem::Action::Exec )
|
||||||
|
{
|
||||||
|
ExecutionViewStep* evs
|
||||||
|
= qobject_cast< ExecutionViewStep* >( Calamares::ViewManager::instance()->viewSteps().last() );
|
||||||
|
if ( !evs ) // If the last step is not an EVS, we must create it.
|
||||||
|
{
|
||||||
|
evs = new ExecutionViewStep( ViewManager::instance() );
|
||||||
|
ViewManager::instance()->addViewStep( evs );
|
||||||
|
}
|
||||||
|
|
||||||
|
evs->appendJobModuleInstanceKey( QString( instanceKey ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( !failedModules.isEmpty() )
|
}
|
||||||
{
|
if ( !failedModules.isEmpty() )
|
||||||
ViewManager::instance()->onInitFailed( failedModules );
|
{
|
||||||
emit modulesFailed( failedModules );
|
ViewManager::instance()->onInitFailed( failedModules );
|
||||||
}
|
emit modulesFailed( failedModules );
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
emit modulesLoaded();
|
{
|
||||||
}
|
emit modulesLoaded();
|
||||||
} );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -79,8 +79,9 @@ public:
|
|||||||
Module* moduleInstance( const QString& instanceKey );
|
Module* moduleInstance( const QString& instanceKey );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief loadModules initiates the asynchronous module loading operation.
|
* @brief loadModules does all of the module loading operation.
|
||||||
* When this is done, the signal modulesLoaded is emitted.
|
* When this is done, the signal modulesLoaded is emitted.
|
||||||
|
* It is recommended to call this from a single-shot QTimer.
|
||||||
*/
|
*/
|
||||||
void loadModules();
|
void loadModules();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user