summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-06-08 14:40:31 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-06-08 14:20:40 +0000
commit8b8ece1ab22bd96bf39c89f1bef3b2662f78dd40 (patch)
treed75eacbf6bdae7e9939b32225f6838747b62370b
parent511f89d6e9b9a554161c4ad42ef46e5ec2914760 (diff)
Restore some of the effects data when deactivating it
We need to restore the visibility tag and the entity or the updateEffects function will eventually crash. Change-Id: Ia2e994c7302dc4d7c097e50bf937c8b80e1cde29 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/runtime/q3dsscenemanager.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp
index 5f0e8eb..a0fd316 100644
--- a/src/runtime/q3dsscenemanager.cpp
+++ b/src/runtime/q3dsscenemanager.cpp
@@ -6229,8 +6229,14 @@ void Q3DSSceneManager::deactivateEffect(Q3DSEffectInstance *eff3DS, Q3DSLayerNod
delete effData->outputTexture;
}
+ // TODO: We only restor the visibility tag, layer and entity,
+ // but there might be other things that needs to be kept...
+ const Q3DSGraphObjectAttached::VisibilityTag visibleTag = effData->visibilityTag;
+ Qt3DCore::QEntity *entity = effData->entity;
*effData = Q3DSEffectAttached();
effData->layer3DS = layer3DS;
+ effData->visibilityTag = visibleTag;
+ effData->entity = entity;
}
void Q3DSSceneManager::setupEffectTextureBuffer(Q3DSEffectAttached::TextureBuffer *tb,
@@ -6812,9 +6818,12 @@ void Q3DSSceneManager::updateSubTree(Q3DSGraphObject *obj)
setNodeVisibility(node, visible);
} else if (it.key()->type() == Q3DSGraphObject::Effect){
Q3DSEffectInstance *effect = static_cast<Q3DSEffectInstance *>(it.key());
- it.key()->attached()->visibilityTag = (it.value() && effect->active()) ? Q3DSGraphObjectAttached::Visible
- : Q3DSGraphObjectAttached::Hidden;
- updateEffectStatus(effect->attached<Q3DSEffectAttached>()->layer3DS);
+ Q3DSEffectAttached *data = effect->attached<Q3DSEffectAttached>();
+ if (data) {
+ it.key()->attached()->visibilityTag = (it.value() && effect->active()) ? Q3DSGraphObjectAttached::Visible
+ : Q3DSGraphObjectAttached::Hidden;
+ updateEffectStatus(effect->attached<Q3DSEffectAttached>()->layer3DS);
+ }
} else if (it.key()->type() == Q3DSGraphObject::Layer) {
Q3DSLayerNode *layer3DS = static_cast<Q3DSLayerNode *>(it.key());
Q3DSLayerAttached *data = static_cast<Q3DSLayerAttached *>(layer3DS->attached());