From e36c8c3763f5cccca1fbada5aa2b3a16dee25cfa Mon Sep 17 00:00:00 2001 From: wraitii Date: Tue, 13 Apr 2021 13:47:59 +0000 Subject: [PATCH] Destroy components in reverse order of construction. Components have some initialisation-order dependency. They could also have destroy-order dependency, and from a RAII-like point of view, it makes sense to do this. Differential Revision: https://code.wildfiregames.com/D3843 This was SVN commit r25251. --- source/simulation2/system/ComponentManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index be9ce6ca61..3346f87bb5 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -459,9 +459,9 @@ void CComponentManager::ResetState() m_DynamicMessageSubscriptionsNonsync.clear(); m_DynamicMessageSubscriptionsNonsyncByComponent.clear(); - // Delete all IComponents - std::map >::iterator iit = m_ComponentsByTypeId.begin(); - for (; iit != m_ComponentsByTypeId.end(); ++iit) + // Delete all IComponents in reverse order of creation. + std::map >::reverse_iterator iit = m_ComponentsByTypeId.rbegin(); + for (; iit != m_ComponentsByTypeId.rend(); ++iit) { std::map::iterator eit = iit->second.begin(); for (; eit != iit->second.end(); ++eit)