History

Fix access-after-delete on leaving domain with entity scripts

Karol Suprynowicz committed 2 years ago

Commit fe4a0971 parent ac20b344 files · +14 −3Browse files

Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 4 files). Show all

Unified · Split

assignment-client/src/scripts/EntityScriptServer.cpp+2−0
@@ -567,6 +567,7 @@ void EntityScriptServer::addingEntity(const EntityItemID& entityID) { · 566 unmodified lines
567567
568568 void EntityScriptServer::deletingEntity(const EntityItemID& entityID) {
569569 if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptManager) {
570+ // TODO: Check if this is running on script engine thread, otherwise lambda capturing script engine pointer is needed
570571 _entitiesScriptManager->unloadEntityScript(entityID, true);
571572 }
572573 }
@@ -584,6 +585,7 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool · 11 unmodified lines
584585 EntityScriptDetails details;
585586 bool isRunning = _entitiesScriptManager->getEntityScriptDetails(entityID, details);
586587 if (entity && (forceRedownload || !isRunning || details.scriptText != entity->getServerScripts())) {
588+ // TODO: Check if this is running on script engine thread, otherwise lambda capturing script engine pointer is needed
587589 if (isRunning) {
588590 _entitiesScriptManager->unloadEntityScript(entityID, true);
589591 }