Merge pull request #11130 from zfox23/contextOverlays_fixCrash1

Fix crash in Context Overlays code
This commit is contained in:
Zach Fox 2017-08-07 11:29:30 -07:00 committed by GitHub
commit 36453644e0

View file

@ -257,15 +257,23 @@ void ContextOverlayInterface::openMarketplace() {
}
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
if (!qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID;
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true);
}
auto entityTree = qApp->getEntities()->getTree();
entityTree->withReadLock([&] {
auto entityItem = entityTree->findEntityByEntityItemID(entityItemID);
if ((entityItem != NULL) && !entityItem->getShouldHighlight()) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID;
entityItem->setShouldHighlight(true);
}
});
}
void ContextOverlayInterface::disableEntityHighlight(const EntityItemID& entityItemID) {
if (qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID;
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(false);
}
auto entityTree = qApp->getEntities()->getTree();
entityTree->withReadLock([&] {
auto entityItem = entityTree->findEntityByEntityItemID(entityItemID);
if ((entityItem != NULL) && entityItem->getShouldHighlight()) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID;
entityItem->setShouldHighlight(false);
}
});
}