Index: ps/trunk/source/simulation2/components/CCmpTest.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpTest.cpp +++ ps/trunk/source/simulation2/components/CCmpTest.cpp @@ -32,6 +32,7 @@ { componentManager.SubscribeToMessageType(MT_TurnStart); componentManager.SubscribeToMessageType(MT_Interpolate); + componentManager.SubscribeToMessageType(MT_Destroy); } DEFAULT_COMPONENT_ALLOCATOR(Test1A) @@ -74,6 +75,9 @@ { switch (msg.GetType()) { + case MT_Destroy: + GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_RenderSubmit, this, false); + break; case MT_TurnStart: m_x += 1; break; Index: ps/trunk/source/simulation2/tests/test_ComponentManager.h =================================================================== --- ps/trunk/source/simulation2/tests/test_ComponentManager.h +++ ps/trunk/source/simulation2/tests/test_ComponentManager.h @@ -854,4 +854,26 @@ TS_ASSERT(man2.DeserializeState(stateStream)); TS_ASSERT_EQUALS(static_cast (man2.QueryInterface(ent2, IID_Test1))->GetX(), 12347); } + + void test_dynamic_subscription() + { + CSimContext context; + CComponentManager man(context, g_ScriptRuntime); + man.LoadComponentTypes(); + + entity_id_t ent1 = 1; + CEntityHandle hnd1 = man.AllocateEntityHandle(ent1); + + CParamNode noParam; + + man.AddComponent(hnd1, CID_Test1A, noParam); + man.AddComponent(hnd1, CID_Test2A, noParam); + + man.DynamicSubscriptionNonsync(MT_RenderSubmit, man.QueryInterface(ent1, IID_Test1), true); + man.DynamicSubscriptionNonsync(MT_RenderSubmit, man.QueryInterface(ent1, IID_Test2), true); + + man.DestroyComponentsSoon(ent1); + man.FlushDestroyedComponents(); + } + };