aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2016-12-16 10:19:40 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2016-12-16 10:18:47 +0000
commit415b873ea3d930f7853f9cf25f6c403e85e07101 (patch)
tree317bd0ed5b788e75d178a55b97cbe1937a8fe614
parent62aa480155f0a5911026ac0ad0001e5058f333e6 (diff)
EvaluatorScriptClass: Catch exceptions from script importing code
Change-Id: I435a3610f0b5eed9eabb012592ef13f36f8c68cc Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 0a2e96c11..73f7e83e2 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -103,6 +103,15 @@ public:
}
private:
+ QScriptValue importScope(Evaluator *evaluator, const FileContextConstPtr &file)
+ {
+ try {
+ return evaluator->importScope(file);
+ } catch (const ErrorInfo &e) {
+ return evaluator->engine()->currentContext()->throwError(e.toString());
+ }
+ }
+
void setupConvenienceProperty(const QString &conveniencePropertyName, QScriptValue *extraScope,
const QScriptValue &scriptValue)
{
@@ -194,7 +203,15 @@ private:
if (alternative->value->definingItem())
pushItemScopes(alternative->value->definingItem());
engine->currentContext()->pushScope(conditionScope);
- engine->currentContext()->pushScope(data->evaluator->importScope(value->file()));
+ const QScriptValue theImportScope = importScope(data->evaluator, value->file());
+ if (theImportScope.isError()) {
+ engine->currentContext()->popScope();
+ engine->currentContext()->popScope();
+ popScopes();
+ *result = theImportScope;
+ return;
+ }
+ engine->currentContext()->pushScope(theImportScope);
const QScriptValue cr = engine->evaluate(alternative->condition);
const QScriptValue overrides = engine->evaluate(alternative->overrideListProperties);
engine->currentContext()->popScope();
@@ -269,9 +286,14 @@ private:
if (value->definingItem())
pushItemScopes(value->definingItem());
pushScope(extraScope);
- pushScope(data->evaluator->importScope(value->file()));
- *result = engine->evaluate(value->sourceCodeForEvaluation(), value->file()->filePath(),
- value->line());
+ const QScriptValue theImportScope = importScope(data->evaluator, value->file());
+ if (theImportScope.isError()) {
+ *result = theImportScope;
+ } else {
+ pushScope(data->evaluator->importScope(value->file()));
+ *result = engine->evaluate(value->sourceCodeForEvaluation(), value->file()->filePath(),
+ value->line());
+ }
popScopes();
}