diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 73be293dd..5b4047d7a 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -269,14 +269,16 @@ Settings::Settings( const QString& settingsFilePath, bool debugMode ) s_instance = this; } -bool -Settings::isModuleEnabled( QString module ) +const bool +Settings::isModuleEnabled( const QString& module ) { // Iterate over the list of modules searching for a match - for ( const auto& moduleInstance : Calamares::Settings::instance()->moduleInstances() ) + for ( const auto& moduleInstance : qAsConst( m_moduleInstances ) ) { if ( moduleInstance.key().first == module ) + { return true; + } } return false; @@ -288,7 +290,7 @@ Settings::reconcileInstancesAndSequence() // Since moduleFinder captures targetKey by reference, we can // update targetKey to change what the finder lambda looks for. Calamares::ModuleSystem::InstanceKey targetKey; - auto moduleFinder = [ &targetKey ]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; }; + auto moduleFinder = [&targetKey]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; }; // Check the sequence against the existing instances (which so far are only custom) for ( const auto& step : m_modulesSequence ) diff --git a/src/libcalamares/Settings.h b/src/libcalamares/Settings.h index 6156a98da..625057f42 100644 --- a/src/libcalamares/Settings.h +++ b/src/libcalamares/Settings.h @@ -152,8 +152,17 @@ public: */ bool isSetupMode() const { return m_isSetupMode; } - /** @brief Returns true if the named module is enabled */ - bool isModuleEnabled( QString module ); + /** @brief Returns whether the named module is enabled + * + * Returns true if @p module is enabled in settings.conf. Be aware that it + * only tests for a specific module name so if a QML and non-QML version + * of the same module exists, it must be specified explicitly + * + * @p module is a module name or module key e.g. packagechooser) and not a + * full module key+id (e.g. packagechooser@packagechooser) + * + */ + const bool isModuleEnabled( const QString& module ); /** @brief Global setting of disable-cancel: can't cancel ever. */ bool disableCancel() const { return m_disableCancel; }