Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 11 files). Show all
Unified · Split
| @@ -2317,6 +2317,8 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID, bool shouldR · 2316 unmodified lines | |||
| 2317 | 2317 | ||
| 2318 | if (_entityScripts.contains(entityID)) { | 2318 | if (_entityScripts.contains(entityID)) { |
| 2319 | const EntityScriptDetails &oldDetails = _entityScripts[entityID]; | 2319 | const EntityScriptDetails &oldDetails = _entityScripts[entityID]; |
| 2320 | auto scriptText = oldDetails.scriptText; | ||
| 2321 | |||
| 2320 | if (isEntityScriptRunning(entityID)) { | 2322 | if (isEntityScriptRunning(entityID)) { |
| 2321 | callEntityScriptMethod(entityID, "unload"); | 2323 | callEntityScriptMethod(entityID, "unload"); |
| 2322 | } | 2324 | } |
| @@ -2334,14 +2336,14 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID, bool shouldR · 11 unmodified lines | |||
| 2334 | newDetails.status = EntityScriptStatus::UNLOADED; | 2336 | newDetails.status = EntityScriptStatus::UNLOADED; |
| 2335 | newDetails.lastModified = QDateTime::currentMSecsSinceEpoch(); | 2337 | newDetails.lastModified = QDateTime::currentMSecsSinceEpoch(); |
| 2336 | // keep scriptText populated for the current need to "debouce" duplicate calls to unloadEntityScript | 2338 | // keep scriptText populated for the current need to "debouce" duplicate calls to unloadEntityScript |
| 2337 | newDetails.scriptText = oldDetails.scriptText; | 2339 | newDetails.scriptText = scriptText; |
| 2338 | setEntityScriptDetails(entityID, newDetails); | 2340 | setEntityScriptDetails(entityID, newDetails); |
| 2339 | } | 2341 | } |
| 2340 | 2342 | ||
| 2341 | stopAllTimersForEntityScript(entityID); | 2343 | stopAllTimersForEntityScript(entityID); |
| 2342 | { | 2344 | { |
| 2343 | // FIXME: shouldn't have to do this here, but currently something seems to be firing unloads moments after firing initial load requests | 2345 | // FIXME: shouldn't have to do this here, but currently something seems to be firing unloads moments after firing initial load requests |
| 2344 | processDeferredEntityLoads(oldDetails.scriptText, entityID); | 2346 | processDeferredEntityLoads(scriptText, entityID); |
| 2345 | } | 2347 | } |
| 2346 | } | 2348 | } |
| 2347 | } | 2349 | } |