Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all
Unified · Split
| @@ -219,6 +219,19 @@ ScriptEngine::ScriptEngine(Context context, const QString& scriptContents, const · 218 unmodified lines | ||
| 219 | 219 | } |
| 220 | 220 | logException(output); |
| 221 | 221 | }); |
| 222 | + | |
| 223 | + if (_type == Type::ENTITY_CLIENT || _type == Type::ENTITY_SERVER) { | |
| 224 | + QObject::connect(this, &ScriptEngine::update, this, [this]() { | |
| 225 | + // process pending entity script content | |
| 226 | + if (_contentAvailableQueue.size()) { | |
| 227 | + auto pending = _contentAvailableQueue.values().toStdList(); | |
| 228 | + _contentAvailableQueue.clear(); | |
| 229 | + for (auto& args : pending) { | |
| 230 | + entityScriptContentAvailable(args.entityID, args.scriptOrURL, args.contents, args.isURL, args.success, args.status); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + }); | |
| 234 | + } | |
| 222 | 235 | } |
| 223 | 236 | |
| 224 | 237 | QString ScriptEngine::getContext() const { |
| @@ -2181,7 +2194,7 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 1956 unmodified lines | ||
| 2181 | 2194 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable" << status << QUrl(url).fileName() << entityID.toString(); |
| 2182 | 2195 | #endif |
| 2183 | 2196 | if (!isStopping() && _entityScripts.contains(entityID)) { |
| 2184 | − entityScriptContentAvailable(entityID, url, contents, isURL, success, status); | |
| 2197 | + _contentAvailableQueue[entityID] = { entityID, url, contents, isURL, success, status }; | |
| 2185 | 2198 | } else { |
| 2186 | 2199 | #ifdef DEBUG_ENTITY_STATES |
| 2187 | 2200 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable -- aborting"; |