Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -79,7 +79,6 @@ void avatarDataFromScriptValue(const QScriptValue &object, AvatarData* &out) { · 78 unmodified lines | ||
| 79 | 79 | QScriptValue inputControllerToScriptValue(QScriptEngine *engine, AbstractInputController* const &in) { |
| 80 | 80 | return engine->newQObject(in); |
| 81 | 81 | } |
| 82 | − | |
| 83 | 82 | void inputControllerFromScriptValue(const QScriptValue &object, AbstractInputController* &out) { |
| 84 | 83 | out = qobject_cast<AbstractInputController*>(object.toQObject()); |
| 85 | 84 | } |
| @@ -95,9 +94,6 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 9 unmodified lines | ||
| 95 | 94 | _wantSignals(wantSignals), |
| 96 | 95 | _controllerScriptingInterface(controllerScriptingInterface), |
| 97 | 96 | _fileNameString(fileNameString), |
| 98 | − _quatLibrary(), | |
| 99 | − _vec3Library(), | |
| 100 | − _uuidLibrary(), | |
| 101 | 97 | _isUserLoaded(false), |
| 102 | 98 | _isReloading(false), |
| 103 | 99 | _arrayBufferClass(new ArrayBufferClass(this)) |
| @@ -654,7 +650,9 @@ void ScriptEngine::run() { · 550 unmodified lines | ||
| 654 | 650 | } |
| 655 | 651 | lastUpdate = now; |
| 656 | 652 | |
| 657 | − checkExceptions(this, _fileNameString); | |
| 653 | + if (!checkExceptions(this, _fileNameString)) { | |
| 654 | + stop(); | |
| 655 | + } | |
| 658 | 656 | } |
| 659 | 657 | |
| 660 | 658 | stopAllTimers(); // make sure all our timers are stopped if the script is ending |
| @@ -891,7 +889,6 @@ void ScriptEngine::load(const QString& loadFile) { · 230 unmodified lines | ||
| 891 | 889 | } |
| 892 | 890 | } |
| 893 | 891 | |
| 894 | − | |
| 895 | 892 | bool ScriptEngine::checkSyntax(const QScriptProgram& program) { |
| 896 | 893 | const auto syntaxCheck = QScriptEngine::checkSyntax(program.sourceCode()); |
| 897 | 894 | if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) { |
| @@ -1005,14 +1002,10 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 107 unmodified lines | ||
| 1005 | 1002 | |
| 1006 | 1003 | auto scriptCache = DependencyManager::get<ScriptCache>(); |
| 1007 | 1004 | bool isFileUrl = isURL && scriptOrURL.startsWith("file://"); |
| 1005 | + auto fileName = QString("(EntityID:%1, %2)").arg(entityID.toString(), isURL ? scriptOrURL : "EmbededEntityScript"); | |
| 1008 | 1006 | |
| 1009 | − // first check the syntax of the script contents | |
| 1010 | − QScriptSyntaxCheckResult syntaxCheck = QScriptEngine::checkSyntax(contents); | |
| 1011 | − if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) { | |
| 1012 | − qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID; | |
| 1013 | − qCDebug(scriptengine) << " " << syntaxCheck.errorMessage() << ":" | |
| 1014 | − << syntaxCheck.errorLineNumber() << syntaxCheck.errorColumnNumber(); | |
| 1015 | − qCDebug(scriptengine) << " SCRIPT:" << scriptOrURL; | |
| 1007 | + QScriptProgram program(contents, fileName); | |
| 1008 | + if (!checkSyntax(program)) { | |
| 1016 | 1009 | if (!isFileUrl) { |
| 1017 | 1010 | scriptCache->addScriptToBadScriptList(scriptOrURL); |
| 1018 | 1011 | } |
| @@ -1027,9 +1020,9 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 8 unmodified lines | ||
| 1027 | 1020 | QScriptValue testConstructor = sandbox.evaluate(contents); |
| 1028 | 1021 | |
| 1029 | 1022 | if (!testConstructor.isFunction()) { |
| 1030 | − qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID; | |
| 1031 | − qCDebug(scriptengine) << " NOT CONSTRUCTOR"; | |
| 1032 | − qCDebug(scriptengine) << " SCRIPT:" << scriptOrURL; | |
| 1023 | + qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n" | |
| 1024 | + " NOT CONSTRUCTOR\n" | |
| 1025 | + " SCRIPT:" << scriptOrURL; | |
| 1033 | 1026 | if (!isFileUrl) { |
| 1034 | 1027 | scriptCache->addScriptToBadScriptList(scriptOrURL); |
| 1035 | 1028 | } |
| @@ -1042,7 +1035,6 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 6 unmodified lines | ||
| 1042 | 1035 | lastModified = (quint64)QFileInfo(file).lastModified().toMSecsSinceEpoch(); |
| 1043 | 1036 | } |
| 1044 | 1037 | |
| 1045 | − auto fileName = QString("(EntityID:%1, %2)").arg(entityID.toString(), isURL ? scriptOrURL : "EmbededEntityScript"); | |
| 1046 | 1038 | QScriptValue entityScriptConstructor = evaluate(contents, fileName); |
| 1047 | 1039 | QScriptValue entityScriptObject = entityScriptConstructor.construct(); |
| 1048 | 1040 | EntityScriptDetails newDetails = { scriptOrURL, entityScriptObject, lastModified }; |