use weak_ptr for fade-out-finished lambda

This commit is contained in:
Andrew Meadows 2019-06-20 09:29:12 -07:00
parent 87d7a0a72f
commit 1ea0dba083

View file

@ -1066,10 +1066,14 @@ void EntityTreeRenderer::fadeOutRenderable(const EntityRendererPointer& renderab
render::Transaction transaction;
auto scene = _viewState->getMain3DScene();
transaction.setTransitionFinishedOperator(renderable->getRenderItemID(), [scene, renderable]() {
render::Transaction transaction;
renderable->removeFromScene(scene, transaction);
scene->enqueueTransaction(transaction);
EntityRendererWeakPointer weakRenderable = renderable;
transaction.setTransitionFinishedOperator(renderable->getRenderItemID(), [scene, weakRenderable]() {
auto renderable = weakRenderable.lock();
if (renderable) {
render::Transaction transaction;
renderable->removeFromScene(scene, transaction);
scene->enqueueTransaction(transaction);
}
});
scene->enqueueTransaction(transaction);