diff options
author | RJ Ryan <rryan@mixxx.org> | 2015-12-22 17:37:44 -0500 |
---|---|---|
committer | RJ Ryan <rryan@mixxx.org> | 2015-12-22 17:37:44 -0500 |
commit | 21951d157a44e38bd96e669a468f4615dd97d3e3 (patch) | |
tree | 4a8e98c0f3b2c97017ddd077846315cd3d0fdccf /src/controllers | |
parent | 32a265bb89662db88bf66983b4b5337c760ec9a4 (diff) |
Return a success indicator from ControllerEngine::loadScriptEngine.
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/controllerengine.cpp | 17 | ||||
-rw-r--r-- | src/controllers/controllerengine.h | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/controllers/controllerengine.cpp b/src/controllers/controllerengine.cpp index e6e18fac54..51c3665974 100644 --- a/src/controllers/controllerengine.cpp +++ b/src/controllers/controllerengine.cpp @@ -207,20 +207,21 @@ void ControllerEngine::initializeScriptEngine() { /* -------- ------------------------------------------------------ Purpose: Load all script files given in the supplied list Input: Global ConfigObject, QString list of file names to load - Output: - + Output: Returns true if no errors occured. -------- ------------------------------------------------------ */ -void ControllerEngine::loadScriptFiles(QList<QString> scriptPaths, - const QList<ControllerPreset::ScriptFileInfo>& scripts) { - qDebug() << "ControllerEngine: Loading & evaluating all script code"; - +bool ControllerEngine::loadScriptFiles(const QList<QString>& scriptPaths, + const QList<ControllerPreset::ScriptFileInfo>& scripts) { m_lastScriptPaths = scriptPaths; // scriptPaths holds the paths to search in when we're looking for scripts + bool result = true; foreach (const ControllerPreset::ScriptFileInfo& script, scripts) { - evaluate(script.name, scriptPaths); + if (!evaluate(script.name, scriptPaths)) { + result = false; + } if (m_scriptErrors.contains(script.name)) { - qDebug() << "Errors occured while loading " << script.name; + qDebug() << "Errors occured while loading" << script.name; } } @@ -228,6 +229,8 @@ void ControllerEngine::loadScriptFiles(QList<QString> scriptPaths, this, SLOT(scriptHasChanged(QString))); emit(initialized()); + + return result && m_scriptErrors.isEmpty(); } // Slot to run when a script file has changed diff --git a/src/controllers/controllerengine.h b/src/controllers/controllerengine.h index 51e8df001e..06be08f71a 100644 --- a/src/controllers/controllerengine.h +++ b/src/controllers/controllerengine.h @@ -128,7 +128,10 @@ class ControllerEngine : public QObject { // Execute a particular function with a data buffer //TODO: redo this one //bool execute(QString function, const QByteArray data); - void loadScriptFiles(QList<QString> scriptPaths, + + // Evaluates all provided script files and returns true if no script errors + // occurred while evaluating them. + bool loadScriptFiles(const QList<QString>& scriptPaths, const QList<ControllerPreset::ScriptFileInfo>& scripts); void initializeScripts(const QList<ControllerPreset::ScriptFileInfo>& scripts); void gracefulShutdown(); |