diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-06-27 17:34:37 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-07-02 11:41:47 +0200 |
commit | 4767c3ee950e4e08d897ccd7c350ab0b3c45412e (patch) | |
tree | f7289c212c95417fb3da88b188ce607996bc9f4e | |
parent | 85e3a10f4068ceb0130ffd986b510faff99b0369 (diff) |
Fix exception leak in JS command execution.
Change-Id: I5fd908cffdb8d2a32d808e85fdb5688873ca555a
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r-- | src/lib/corelib/buildgraph/jscommandexecutor.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.cpp b/src/lib/corelib/buildgraph/jscommandexecutor.cpp index cc7eb715b..a29b5903a 100644 --- a/src/lib/corelib/buildgraph/jscommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/jscommandexecutor.cpp @@ -83,6 +83,18 @@ signals: public slots: void start(const JavaScriptCommand *cmd, Transformer *transformer) { + try { + doStart(cmd, transformer); + } catch (const qbs::ErrorInfo &error) { + setError(error.toString(), cmd->codeLocation()); + } + + emit finished(); + } + +private: + void doStart(const JavaScriptCommand *cmd, Transformer *transformer) + { m_result.success = true; m_result.errorMessage.clear(); ScriptEngine * const scriptEngine = provideScriptEngine(); @@ -107,15 +119,18 @@ public slots: += scriptEngine->propertiesRequestedInScript(); scriptEngine->clearRequestedProperties(); if (scriptEngine->hasUncaughtException()) { - m_result.success = false; - m_result.errorMessage = scriptEngine->uncaughtException().toString(); // ### We don't know the line number of the command's sourceCode property assignment. - m_result.errorLocation = cmd->codeLocation(); + setError(scriptEngine->uncaughtException().toString(), cmd->codeLocation()); } - emit finished(); } -private: + void setError(const QString &errorMessage, const CodeLocation &codeLocation) + { + m_result.success = false; + m_result.errorMessage = errorMessage; + m_result.errorLocation = codeLocation; + } + ScriptEngine *provideScriptEngine() { if (!m_scriptEngine) |