From f2fc5089fe8bc59c96a58de4d9e33935c9944c7c Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 12 Nov 2022 16:00:21 +0100 Subject: [PATCH] #6158: Fix crash due to race condition in EntityPreview --- libs/wxutil/preview/EntityPreview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/wxutil/preview/EntityPreview.cpp b/libs/wxutil/preview/EntityPreview.cpp index c42daf8af..02e507fc7 100644 --- a/libs/wxutil/preview/EntityPreview.cpp +++ b/libs/wxutil/preview/EntityPreview.cpp @@ -33,14 +33,15 @@ void EntityPreview::setEntity(const IEntityNodePtr& entity) if (_entity) { - _rootNode->removeChildNode(_entity); + // Use getScene to access the root node to ensure it's created + getScene()->root()->removeChildNode(_entity); } _entity = entity; if (_entity) { - _rootNode->addChildNode(_entity); + getScene()->root()->addChildNode(_entity); // Remember the entity bounds including children _untransformedEntityBounds = _entity->worldAABB();