Add null check to entity render clearing to fix crash.

Co-Authored-By: null <HifiExperiments@users.noreply.github.com>
This commit is contained in:
Kasen IO 2020-06-01 22:13:52 -04:00
parent 079c0c022e
commit 94c230b78b

View file

@ -248,7 +248,7 @@ void EntityTreeRenderer::clearDomainAndNonOwnedEntities() {
for (const auto& entry : _entitiesInScene) {
const auto& renderer = entry.second;
const EntityItemPointer& entityItem = renderer->getEntity();
if (!(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) {
if (entityItem && !(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) {
fadeOutRenderable(renderer);
} else {
savedEntities[entry.first] = entry.second;
@ -682,7 +682,7 @@ void EntityTreeRenderer::leaveDomainAndNonOwnedEntities() {
QSet<EntityItemID> currentEntitiesInsideToSave;
foreach (const EntityItemID& entityID, _currentEntitiesInside) {
EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID);
if (!(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) {
if (entityItem && !(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) {
emit leaveEntity(entityID);
if (_entitiesScriptEngine) {
_entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity");