From 4df5ec776cc40a4872c5a353402aa0fe0b24a7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Feb 2017 16:27:55 +0100 Subject: [PATCH] Sdk/Entity: Fix entity destruction not calling Component::OnDetached --- SDK/src/NDK/Entity.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index ce72aca62..d88556a31 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -158,11 +158,16 @@ namespace Ndk } m_systemBits.Clear(); - UnregisterAllHandles(); + // We properly destroy each component + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + m_components[i]->SetEntity(nullptr); m_components.clear(); m_componentBits.Reset(); + // And then free every handle + UnregisterAllHandles(); + m_valid = false; }