From a40c36ef493b6a5596515d9d288cc4c91e270834 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 11 Jun 2018 05:59:56 -0400 Subject: [PATCH] [libcalamaresui] Report on failed module loading - Collect the failed modules, instead of bailing out on the first one (this also prevents crashes caused by quit() called from a timer). - Introduce a slot to report on failed module loading (no UI yet). --- src/calamares/CalamaresApplication.cpp | 8 ++++++ src/calamares/CalamaresApplication.h | 1 + .../modulesystem/ModuleManager.cpp | 28 +++++++++++-------- .../modulesystem/ModuleManager.h | 3 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 2bb0af8df..2f61749b0 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -335,6 +335,8 @@ CalamaresApplication::initView() connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps ); + connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, + this, &CalamaresApplication::initFailed ); m_moduleManager->loadModules(); @@ -356,6 +358,12 @@ CalamaresApplication::initViewSteps() cDebug() << "STARTUP: Window now visible and ProgressTreeView populated"; } +void +CalamaresApplication::initFailed(const QStringList& l) +{ + cError() << "STARTUP: failed modules are" << l; + m_mainwindow->show(); +} void CalamaresApplication::initJobQueue() diff --git a/src/calamares/CalamaresApplication.h b/src/calamares/CalamaresApplication.h index 3cfd4f79f..a588afcee 100644 --- a/src/calamares/CalamaresApplication.h +++ b/src/calamares/CalamaresApplication.h @@ -70,6 +70,7 @@ public: private slots: void initView(); void initViewSteps(); + void initFailed( const QStringList& l ); private: void initQmlPath(); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 48a2c1476..57a82994f 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -181,6 +181,7 @@ ModuleManager::loadModules() QTimer::singleShot( 0, this, [ this ]() { + QStringList failedModules; Settings::InstanceDescriptionList customInstances = Settings::instance()->customModuleInstances(); @@ -201,8 +202,8 @@ ModuleManager::loadModules() { cError() << "Wrong module entry format for module" << moduleEntry << '.' << GOODBYE; - qApp->exit( 1 ); - return; + failedModules.append( moduleEntry ); + continue; } moduleName = moduleEntrySplit.first(); instanceId = moduleEntrySplit.last(); @@ -214,8 +215,8 @@ ModuleManager::loadModules() cError() << "Module" << moduleName << "not found in module search paths." << Logger::DebugList( m_paths ) << GOODBYE; - qApp->exit( 1 ); - return; + failedModules.append( moduleName ); + continue; } if ( moduleName != instanceId ) //means this is a custom instance @@ -228,8 +229,8 @@ ModuleManager::loadModules() { cError() << "Custom instance" << moduleEntry << "not found in custom instances section." << GOODBYE; - qApp->exit( 1 ); - return; + failedModules.append( moduleEntry ); + continue; } } @@ -251,8 +252,8 @@ ModuleManager::loadModules() { cError() << "Module" << instanceKey << "exists but not loaded." << GOODBYE; - qApp->exit( 1 ); - return; + failedModules.append( instanceKey ); + continue; } if ( thisModule && thisModule->isLoaded() ) @@ -270,7 +271,8 @@ ModuleManager::loadModules() { cError() << "Module" << instanceKey << "cannot be created from descriptor" << configFileName << GOODBYE; - qApp->exit( 1 ); + failedModules.append( instanceKey ); + continue; } // If it's a ViewModule, it also appends the ViewStep to the ViewManager. thisModule->loadSelf(); @@ -279,7 +281,8 @@ ModuleManager::loadModules() { cError() << "Module" << instanceKey << "loading FAILED" << GOODBYE; - qApp->exit( 1 ); + failedModules.append( instanceKey ); + continue; } } @@ -300,7 +303,10 @@ ModuleManager::loadModules() } } } - emit modulesLoaded(); + if ( !failedModules.isEmpty() ) + emit modulesFailed( failedModules ); + else + emit modulesLoaded(); } ); } diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index ed7700c40..e1763d93c 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -82,7 +82,8 @@ public: signals: void initDone(); - void modulesLoaded(); + void modulesLoaded(); /// All of the modules were loaded successfully + void modulesFailed( QStringList ); /// .. or not private slots: void doInit();