avoid a rare crash

This commit is contained in:
Seth Alves 2017-02-25 11:35:27 -08:00
parent 76c873ce81
commit 0e4b0332dd

View file

@ -944,7 +944,10 @@ void EntityTreeRenderer::entityScriptChanging(const EntityItemID& entityID, cons
void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, const bool reload, const bool unloadFirst) {
if (_tree && !_shuttingDown) {
EntityItemPointer entity = getTree()->findEntityByEntityItemID(entityID);
bool shouldLoad = entity && entity->shouldPreloadScript() && _entitiesScriptEngine;
if (!entity) {
return;
}
bool shouldLoad = entity->shouldPreloadScript() && _entitiesScriptEngine;
QString scriptUrl = entity->getScript();
if ((unloadFirst && shouldLoad) || scriptUrl.isEmpty()) {
_entitiesScriptEngine->unloadEntityScript(entityID);