diff --git a/inc/hgl/graph/module/GraphModule.h b/inc/hgl/graph/module/GraphModule.h index cdb5d8a2..bc67c39c 100644 --- a/inc/hgl/graph/module/GraphModule.h +++ b/inc/hgl/graph/module/GraphModule.h @@ -13,7 +13,9 @@ class GraphModuleManager { GPUDevice *device; - Map graph_module_map; + List module_list; ///<模块列表 + + Map graph_module_map; ///<模块映射表 public: @@ -86,12 +88,8 @@ public: NO_COPY_NO_MOVE(GraphModule) - GraphModule(GraphModuleManager *gmm,const AnsiIDName &name) - { - module_manager=gmm; - module_name=name; - } - virtual ~GraphModule()=default; + GraphModule(GraphModuleManager *gmm,const AnsiIDName &name); + virtual ~GraphModule(); virtual bool Init(){return true;} ///<初始化当前模块 diff --git a/src/SceneGraph/Vulkan/VKSwapchainRenderTarget.cpp b/src/SceneGraph/Vulkan/VKSwapchainRenderTarget.cpp index 5e533a79..143dc13d 100644 --- a/src/SceneGraph/Vulkan/VKSwapchainRenderTarget.cpp +++ b/src/SceneGraph/Vulkan/VKSwapchainRenderTarget.cpp @@ -27,7 +27,6 @@ RTSwapchain::RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rc RTSwapchain::~RTSwapchain() { delete present_complete_semaphore; - delete swapchain; } uint32_t RTSwapchain::AcquireNextImage() diff --git a/src/SceneGraph/module/GraphModule.cpp b/src/SceneGraph/module/GraphModule.cpp index b9166ddb..4d6f2117 100644 --- a/src/SceneGraph/module/GraphModule.cpp +++ b/src/SceneGraph/module/GraphModule.cpp @@ -1,7 +1,20 @@ #include #include +#include VK_NAMESPACE_BEGIN +GraphModule::GraphModule(GraphModuleManager *gmm,const AnsiIDName &name) +{ + module_manager=gmm; + module_name=name; + + LOG_INFO("GraphModule::GraphModule: "+AnsiString(module_name.GetName())) +} + +GraphModule::~GraphModule() +{ + LOG_INFO("GraphModule::~GraphModule: "+AnsiString(module_name.GetName())) +} VK_NAMESPACE_END diff --git a/src/SceneGraph/module/GraphModuleManager.cpp b/src/SceneGraph/module/GraphModuleManager.cpp index def50e9f..1931f563 100644 --- a/src/SceneGraph/module/GraphModuleManager.cpp +++ b/src/SceneGraph/module/GraphModuleManager.cpp @@ -94,7 +94,10 @@ GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create) gm=CreateGraphModule(name,this); if(gm) + { graph_module_map.Add(name,gm); + module_list.Add(gm); + } return gm; } @@ -104,10 +107,19 @@ GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create) GraphModuleManager::~GraphModuleManager() { - for(auto *gm:graph_module_map) + //按顺序加入module_list的,要倒着释放 + + GraphModule **gm=module_list.end(); + + while(gm>module_list.begin()) { - delete gm->value; + --gm; + delete *gm; } + + //其实下面释不释放都无所谓了 + module_list.Clear(); + graph_module_map.Clear(); } void GraphModuleManager::ReleaseModule(GraphModule *gm)