[libcalamaresui] Error out consistently when module loading fails

- Some module-loading failures were ignored and produce only a
   warning, instead of erroring out.
This commit is contained in:
Adriaan de Groot 2018-06-08 18:14:51 -04:00
parent dccf6f16f5
commit 1999e4e5c2

View File

@ -177,6 +177,8 @@ static int findCustomInstance( const Settings::InstanceDescriptionList& customIn
void void
ModuleManager::loadModules() ModuleManager::loadModules()
{ {
static const char GOODBYE[] = "\nCalamares will now quit.";
QTimer::singleShot( 0, this, [ this ]() QTimer::singleShot( 0, this, [ this ]()
{ {
Settings::InstanceDescriptionList customInstances = Settings::InstanceDescriptionList customInstances =
@ -197,8 +199,8 @@ ModuleManager::loadModules()
if ( moduleEntrySplit.length() < 1 || if ( moduleEntrySplit.length() < 1 ||
moduleEntrySplit.length() > 2 ) moduleEntrySplit.length() > 2 )
{ {
cError() << "Wrong module entry format for module" << moduleEntry << '.'; cError() << "Wrong module entry format for module" << moduleEntry << '.'
cError() << "Calamares will now quit."; << GOODBYE;
qApp->exit( 1 ); qApp->exit( 1 );
return; return;
} }
@ -210,8 +212,8 @@ ModuleManager::loadModules()
m_availableDescriptorsByModuleName.value( moduleName ).isEmpty() ) m_availableDescriptorsByModuleName.value( moduleName ).isEmpty() )
{ {
cError() << "Module" << moduleName << "not found in module search paths." cError() << "Module" << moduleName << "not found in module search paths."
<< Logger::DebugList( m_paths ); << Logger::DebugList( m_paths )
cError() << "Calamares will now quit."; << GOODBYE;
qApp->exit( 1 ); qApp->exit( 1 );
return; return;
} }
@ -224,8 +226,8 @@ ModuleManager::loadModules()
} }
else //ought to be a custom instance, but cannot find instance entry else //ought to be a custom instance, but cannot find instance entry
{ {
cError() << "Custom instance" << moduleEntry << "not found in custom instances section."; cError() << "Custom instance" << moduleEntry << "not found in custom instances section."
cError() << "Calamares will now quit."; << GOODBYE;
qApp->exit( 1 ); qApp->exit( 1 );
return; return;
} }
@ -248,7 +250,7 @@ ModuleManager::loadModules()
if ( thisModule && !thisModule->isLoaded() ) if ( thisModule && !thisModule->isLoaded() )
{ {
cError() << "Module" << instanceKey << "exists but not loaded." cError() << "Module" << instanceKey << "exists but not loaded."
<< "\nCalamares will now quit."; << GOODBYE;
qApp->exit( 1 ); qApp->exit( 1 );
return; return;
} }
@ -266,18 +268,18 @@ ModuleManager::loadModules()
m_moduleDirectoriesByModuleName.value( moduleName ) ); m_moduleDirectoriesByModuleName.value( moduleName ) );
if ( !thisModule ) if ( !thisModule )
{ {
cWarning() << "Module" << instanceKey << "cannot be created from descriptor."; cError() << "Module" << instanceKey << "cannot be created from descriptor" << configFileName
Q_ASSERT( thisModule ); << GOODBYE;
continue; qApp->exit( 1 );
} }
// If it's a ViewModule, it also appends the ViewStep to the ViewManager. // If it's a ViewModule, it also appends the ViewStep to the ViewManager.
thisModule->loadSelf(); thisModule->loadSelf();
m_loadedModulesByInstanceKey.insert( instanceKey, thisModule ); m_loadedModulesByInstanceKey.insert( instanceKey, thisModule );
if ( !thisModule->isLoaded() ) if ( !thisModule->isLoaded() )
{ {
cWarning() << "Module" << moduleName << "loading FAILED"; cError() << "Module" << instanceKey << "loading FAILED"
Q_ASSERT( thisModule->isLoaded() ); << GOODBYE;
continue; qApp->exit( 1 );
} }
} }