Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 105 files). Show all
Unified · Split
| @@ -219,6 +219,20 @@ ScriptEngine::ScriptEngine(Context context, const QString& scriptContents, const · 218 unmodified lines | |||
| 219 | } | 219 | } |
| 220 | logException(output); | 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.empty()) { | ||
| 227 | EntityScriptContentAvailableMap pending; | ||
| 228 | std::swap(_contentAvailableQueue, pending); | ||
| 229 | for (auto& pair : pending) { | ||
| 230 | auto& args = pair.second; | ||
| 231 | entityScriptContentAvailable(args.entityID, args.scriptOrURL, args.contents, args.isURL, args.success, args.status); | ||
| 232 | } | ||
| 233 | } | ||
| 234 | }); | ||
| 235 | } | ||
| 222 | } | 236 | } |
| 223 | 237 | ||
| 224 | QString ScriptEngine::getContext() const { | 238 | QString ScriptEngine::getContext() const { |
| @@ -2181,7 +2195,7 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 1956 unmodified lines | |||
| 2181 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable" << status << QUrl(url).fileName() << entityID.toString(); | 2195 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable" << status << QUrl(url).fileName() << entityID.toString(); |
| 2182 | #endif | 2196 | #endif |
| 2183 | if (!isStopping() && _entityScripts.contains(entityID)) { | 2197 | if (!isStopping() && _entityScripts.contains(entityID)) { |
| 2184 | entityScriptContentAvailable(entityID, url, contents, isURL, success, status); | 2198 | _contentAvailableQueue[entityID] = { entityID, url, contents, isURL, success, status }; |
| 2185 | } else { | 2199 | } else { |
| 2186 | #ifdef DEBUG_ENTITY_STATES | 2200 | #ifdef DEBUG_ENTITY_STATES |
| 2187 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable -- aborting"; | 2201 | qCDebug(scriptengine) << "loadEntityScript.contentAvailable -- aborting"; |