History

checkExceptions after testing entity scripts in the sandbox

Atlante45 committed 11 years ago

Commit 38013931 parent 1c048882 files · +14 −11Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all

Unified · Split

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