Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all
Unified · Split
| @@ -65,9 +65,9 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ · 64 unmodified lines | ||
| 65 | 65 | qCDebug(scriptengine).noquote() << "script:print()<<" << message; // noquote() so that \n is treated as newline |
| 66 | 66 | |
| 67 | 67 | message = message.replace("\\", "\\\\") |
| 68 | − .replace("\n", "\\n") | |
| 69 | − .replace("\r", "\\r") | |
| 70 | − .replace("'", "\\'"); | |
| 68 | + .replace("\n", "\\n") | |
| 69 | + .replace("\r", "\\r") | |
| 70 | + .replace("'", "\\'"); | |
| 71 | 71 | engine->evaluate("Script.print('" + message + "')"); |
| 72 | 72 | |
| 73 | 73 | return QScriptValue(); |
| @@ -123,11 +123,11 @@ static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName · 49 unmodified lines | ||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString, bool wantSignals) : |
| 126 | −_scriptContents(scriptContents), | |
| 127 | −_timerFunctionMap(), | |
| 128 | −_wantSignals(wantSignals), | |
| 129 | −_fileNameString(fileNameString), | |
| 130 | −_arrayBufferClass(new ArrayBufferClass(this)) | |
| 126 | + _scriptContents(scriptContents), | |
| 127 | + _timerFunctionMap(), | |
| 128 | + _wantSignals(wantSignals), | |
| 129 | + _fileNameString(fileNameString), | |
| 130 | + _arrayBufferClass(new ArrayBufferClass(this)) | |
| 131 | 131 | { |
| 132 | 132 | _allScriptsMutex.lock(); |
| 133 | 133 | _allKnownScriptEngines.insert(this); |
| @@ -495,7 +495,7 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func · 361 unmodified lines | ||
| 495 | 495 | if (QThread::currentThread() != thread()) { |
| 496 | 496 | #ifdef THREAD_DEBUGGING |
| 497 | 497 | qDebug() << "*** WARNING *** ScriptEngine::registerGetterSetter() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 498 | − " name:" << name << "parent:" << parent; | |
| 498 | + " name:" << name << "parent:" << parent; | |
| 499 | 499 | #endif |
| 500 | 500 | QMetaObject::invokeMethod(this, "registerGetterSetter", |
| 501 | 501 | Q_ARG(const QString&, name), |
| @@ -528,7 +528,7 @@ void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QStrin · 26 unmodified lines | ||
| 528 | 528 | if (QThread::currentThread() != thread()) { |
| 529 | 529 | #ifdef THREAD_DEBUGGING |
| 530 | 530 | qDebug() << "*** WARNING *** ScriptEngine::removeEventHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 531 | − "entityID:" << entityID << " eventName:" << eventName; | |
| 531 | + "entityID:" << entityID << " eventName:" << eventName; | |
| 532 | 532 | #endif |
| 533 | 533 | QMetaObject::invokeMethod(this, "removeEventHandler", |
| 534 | 534 | Q_ARG(const EntityItemID&, entityID), |
| @@ -955,7 +955,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 420 unmodified lines | ||
| 955 | 955 | void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { |
| 956 | 956 | if (_stoppingAllScripts) { |
| 957 | 957 | qCDebug(scriptengine) << "Script.include() while shutting down is ignored... " |
| 958 | − << "includeFile:" << includeFile << "parent script:" << getFilename(); | |
| 958 | + << "includeFile:" << includeFile << "parent script:" << getFilename(); | |
| 959 | 959 | return; // bail early |
| 960 | 960 | } |
| 961 | 961 | |
| @@ -970,7 +970,7 @@ void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { · 8 unmodified lines | ||
| 970 | 970 | void ScriptEngine::load(const QString& loadFile) { |
| 971 | 971 | if (_stoppingAllScripts) { |
| 972 | 972 | qCDebug(scriptengine) << "Script.load() while shutting down is ignored... " |
| 973 | − << "loadFile:" << loadFile << "parent script:" << getFilename(); | |
| 973 | + << "loadFile:" << loadFile << "parent script:" << getFilename(); | |
| 974 | 974 | return; // bail early |
| 975 | 975 | } |
| 976 | 976 | |
| @@ -1016,7 +1016,7 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 39 unmodified lines | ||
| 1016 | 1016 | if (QThread::currentThread() != thread()) { |
| 1017 | 1017 | #ifdef THREAD_DEBUGGING |
| 1018 | 1018 | qDebug() << "*** WARNING *** ScriptEngine::loadEntityScript() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1019 | − "entityID:" << entityID << "entityScript:" << entityScript <<"forceRedownload:" << forceRedownload; | |
| 1019 | + "entityID:" << entityID << "entityScript:" << entityScript <<"forceRedownload:" << forceRedownload; | |
| 1020 | 1020 | #endif |
| 1021 | 1021 | |
| 1022 | 1022 | QMetaObject::invokeMethod(this, "loadEntityScript", |
| @@ -1027,18 +1027,20 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 4 unmodified lines | ||
| 1027 | 1027 | } |
| 1028 | 1028 | #ifdef THREAD_DEBUGGING |
| 1029 | 1029 | qDebug() << "ScriptEngine::loadEntityScript() called on correct thread [" << thread() << "] " |
| 1030 | − "entityID:" << entityID << "entityScript:" << entityScript << "forceRedownload:" << forceRedownload; | |
| 1030 | + "entityID:" << entityID << "entityScript:" << entityScript << "forceRedownload:" << forceRedownload; | |
| 1031 | 1031 | #endif |
| 1032 | 1032 | |
| 1033 | 1033 | // If we've been called our known entityScripts should not know about us.. |
| 1034 | 1034 | assert(!_entityScripts.contains(entityID)); |
| 1035 | 1035 | |
| 1036 | 1036 | #ifdef THREAD_DEBUGGING |
| 1037 | − qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 1037 | + qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread [" | |
| 1038 | + << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 1038 | 1039 | #endif |
| 1039 | 1040 | DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [=](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) { |
| 1040 | 1041 | #ifdef THREAD_DEBUGGING |
| 1041 | − qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 1042 | + qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread [" | |
| 1043 | + << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 1042 | 1044 | #endif |
| 1043 | 1045 | |
| 1044 | 1046 | this->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success); |
| @@ -1091,11 +1093,13 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 46 unmodified lines | ||
| 1091 | 1093 | |
| 1092 | 1094 | if (!testConstructor.isFunction()) { |
| 1093 | 1095 | qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n" |
| 1094 | − " NOT CONSTRUCTOR\n" | |
| 1095 | − " SCRIPT:" << scriptOrURL; | |
| 1096 | + " NOT CONSTRUCTOR\n" | |
| 1097 | + " SCRIPT:" << scriptOrURL; | |
| 1098 | + | |
| 1096 | 1099 | if (!isFileUrl) { |
| 1097 | 1100 | scriptCache->addScriptToBadScriptList(scriptOrURL); |
| 1098 | 1101 | } |
| 1102 | + | |
| 1099 | 1103 | return; // done processing script |
| 1100 | 1104 | } |
| 1101 | 1105 | |
| @@ -1121,7 +1125,7 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 19 unmodified lines | ||
| 1121 | 1125 | if (QThread::currentThread() != thread()) { |
| 1122 | 1126 | #ifdef THREAD_DEBUGGING |
| 1123 | 1127 | qDebug() << "*** WARNING *** ScriptEngine::unloadEntityScript() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1124 | − "entityID:" << entityID; | |
| 1128 | + "entityID:" << entityID; | |
| 1125 | 1129 | #endif |
| 1126 | 1130 | |
| 1127 | 1131 | QMetaObject::invokeMethod(this, "unloadEntityScript", |
| @@ -1130,7 +1134,7 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 2 unmodified lines | ||
| 1130 | 1134 | } |
| 1131 | 1135 | #ifdef THREAD_DEBUGGING |
| 1132 | 1136 | qDebug() << "ScriptEngine::unloadEntityScript() called on correct thread [" << thread() << "] " |
| 1133 | − "entityID:" << entityID; | |
| 1137 | + "entityID:" << entityID; | |
| 1134 | 1138 | #endif |
| 1135 | 1139 | |
| 1136 | 1140 | if (_entityScripts.contains(entityID)) { |
| @@ -1195,7 +1199,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 58 unmodified lines | ||
| 1195 | 1199 | if (QThread::currentThread() != thread()) { |
| 1196 | 1200 | #ifdef THREAD_DEBUGGING |
| 1197 | 1201 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1198 | − "entityID:" << entityID << "methodName:" << methodName; | |
| 1202 | + "entityID:" << entityID << "methodName:" << methodName; | |
| 1199 | 1203 | #endif |
| 1200 | 1204 | |
| 1201 | 1205 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| @@ -1206,7 +1210,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 4 unmodified lines | ||
| 1206 | 1210 | } |
| 1207 | 1211 | #ifdef THREAD_DEBUGGING |
| 1208 | 1212 | qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] " |
| 1209 | − "entityID:" << entityID << "methodName:" << methodName; | |
| 1213 | + "entityID:" << entityID << "methodName:" << methodName; | |
| 1210 | 1214 | #endif |
| 1211 | 1215 | |
| 1212 | 1216 | refreshFileScript(entityID); |
| @@ -1227,7 +1231,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 14 unmodified lines | ||
| 1227 | 1231 | if (QThread::currentThread() != thread()) { |
| 1228 | 1232 | #ifdef THREAD_DEBUGGING |
| 1229 | 1233 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1230 | − "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent"; | |
| 1234 | + "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent"; | |
| 1231 | 1235 | #endif |
| 1232 | 1236 | |
| 1233 | 1237 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| @@ -1238,7 +1242,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 4 unmodified lines | ||
| 1238 | 1242 | } |
| 1239 | 1243 | #ifdef THREAD_DEBUGGING |
| 1240 | 1244 | qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] " |
| 1241 | − "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent"; | |
| 1245 | + "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent"; | |
| 1242 | 1246 | #endif |
| 1243 | 1247 | |
| 1244 | 1248 | refreshFileScript(entityID); |
| @@ -1259,7 +1263,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 14 unmodified lines | ||
| 1259 | 1263 | if (QThread::currentThread() != thread()) { |
| 1260 | 1264 | #ifdef THREAD_DEBUGGING |
| 1261 | 1265 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1262 | − "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision"; | |
| 1266 | + "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision"; | |
| 1263 | 1267 | #endif |
| 1264 | 1268 | |
| 1265 | 1269 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| @@ -1271,7 +1275,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 5 unmodified lines | ||
| 1271 | 1275 | } |
| 1272 | 1276 | #ifdef THREAD_DEBUGGING |
| 1273 | 1277 | qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] " |
| 1274 | − "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision"; | |
| 1278 | + "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision"; | |
| 1275 | 1279 | #endif |
| 1276 | 1280 | |
| 1277 | 1281 | refreshFileScript(entityID); |