Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all
Unified · Split
| @@ -585,7 +585,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 584 unmodified lines | ||
| 585 | 585 | const auto result = QScriptEngine::evaluate(program); |
| 586 | 586 | --_evaluatesPending; |
| 587 | 587 | |
| 588 | − const auto hadUncaughtException = checkExceptions(this, program.fileName()); | |
| 588 | + const auto hadUncaughtException = checkExceptions(*this, program.fileName()); | |
| 589 | 589 | if (_wantSignals) { |
| 590 | 590 | emit evaluationFinished(result, hadUncaughtException); |
| 591 | 591 | } |
| @@ -654,7 +654,7 @@ void ScriptEngine::run() { · 62 unmodified lines | ||
| 654 | 654 | } |
| 655 | 655 | lastUpdate = now; |
| 656 | 656 | |
| 657 | − if (!checkExceptions(this, _fileNameString)) { | |
| 657 | + if (!checkExceptions(*this, _fileNameString)) { | |
| 658 | 658 | stop(); |
| 659 | 659 | } |
| 660 | 660 | } |
| @@ -906,12 +906,12 @@ bool ScriptEngine::checkSyntax(const QScriptProgram& program) { · 245 unmodified lines | ||
| 906 | 906 | return true; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | −bool ScriptEngine::checkExceptions(QScriptEngine* engine, const QString& fileName) { | |
| 910 | − if (engine->hasUncaughtException()) { | |
| 911 | − const auto backtrace = engine->uncaughtExceptionBacktrace(); | |
| 912 | − const auto exception = engine->uncaughtException().toString(); | |
| 913 | − const auto line = QString::number(engine->uncaughtExceptionLineNumber()); | |
| 914 | − engine->clearExceptions(); | |
| 909 | +bool ScriptEngine::checkExceptions(QScriptEngine& engine, const QString& fileName) { | |
| 910 | + if (engine.hasUncaughtException()) { | |
| 911 | + const auto backtrace = engine.uncaughtExceptionBacktrace(); | |
| 912 | + const auto exception = engine.uncaughtException().toString(); | |
| 913 | + const auto line = QString::number(engine.uncaughtExceptionLineNumber()); | |
| 914 | + engine.clearExceptions(); | |
| 915 | 915 | |
| 916 | 916 | auto message = QString("[UncaughtException] %1 in %2:%3").arg(exception, fileName, line); |
| 917 | 917 | if (!backtrace.empty()) { |
| @@ -1021,8 +1021,11 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 103 unmodified lines | ||
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | QScriptEngine sandbox; |
| 1024 | − QScriptValue testConstructor = sandbox.evaluate(contents); | |
| 1025 | − | |
| 1024 | + QScriptValue testConstructor = sandbox.evaluate(program); | |
| 1025 | + if (!checkExceptions(sandbox, program.fileName())) { | |
| 1026 | + return; | |
| 1027 | + } | |
| 1028 | + | |
| 1026 | 1029 | if (!testConstructor.isFunction()) { |
| 1027 | 1030 | qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n" |
| 1028 | 1031 | " NOT CONSTRUCTOR\n" |