mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:13:42 +02:00
checkExceptions after testing entity scripts in the sandbox
This commit is contained in:
parent
ea56f965a4
commit
a53a576aa3
2 changed files with 14 additions and 11 deletions
|
@ -585,7 +585,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi
|
|||
const auto result = QScriptEngine::evaluate(program);
|
||||
--_evaluatesPending;
|
||||
|
||||
const auto hadUncaughtException = checkExceptions(this, program.fileName());
|
||||
const auto hadUncaughtException = checkExceptions(*this, program.fileName());
|
||||
if (_wantSignals) {
|
||||
emit evaluationFinished(result, hadUncaughtException);
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ void ScriptEngine::run() {
|
|||
}
|
||||
lastUpdate = now;
|
||||
|
||||
if (!checkExceptions(this, _fileNameString)) {
|
||||
if (!checkExceptions(*this, _fileNameString)) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
@ -906,12 +906,12 @@ bool ScriptEngine::checkSyntax(const QScriptProgram& program) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ScriptEngine::checkExceptions(QScriptEngine* engine, const QString& fileName) {
|
||||
if (engine->hasUncaughtException()) {
|
||||
const auto backtrace = engine->uncaughtExceptionBacktrace();
|
||||
const auto exception = engine->uncaughtException().toString();
|
||||
const auto line = QString::number(engine->uncaughtExceptionLineNumber());
|
||||
engine->clearExceptions();
|
||||
bool ScriptEngine::checkExceptions(QScriptEngine& engine, const QString& fileName) {
|
||||
if (engine.hasUncaughtException()) {
|
||||
const auto backtrace = engine.uncaughtExceptionBacktrace();
|
||||
const auto exception = engine.uncaughtException().toString();
|
||||
const auto line = QString::number(engine.uncaughtExceptionLineNumber());
|
||||
engine.clearExceptions();
|
||||
|
||||
auto message = QString("[UncaughtException] %1 in %2:%3").arg(exception, fileName, line);
|
||||
if (!backtrace.empty()) {
|
||||
|
@ -1021,8 +1021,11 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
|||
}
|
||||
|
||||
QScriptEngine sandbox;
|
||||
QScriptValue testConstructor = sandbox.evaluate(contents);
|
||||
|
||||
QScriptValue testConstructor = sandbox.evaluate(program);
|
||||
if (!checkExceptions(sandbox, program.fileName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!testConstructor.isFunction()) {
|
||||
qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n"
|
||||
" NOT CONSTRUCTOR\n"
|
||||
|
|
|
@ -183,7 +183,7 @@ private:
|
|||
void stopTimer(QTimer* timer);
|
||||
|
||||
static bool checkSyntax(const QScriptProgram& program);
|
||||
static bool checkExceptions(QScriptEngine* engine, const QString& fileName);
|
||||
static bool checkExceptions(QScriptEngine& engine, const QString& fileName);
|
||||
|
||||
AbstractControllerScriptingInterface* _controllerScriptingInterface;
|
||||
QString _fileNameString;
|
||||
|
|
Loading…
Reference in a new issue