Fixed memory leak in ResourceSaveLoadMathGraphInputs test.

RefactorUnifiedBlendTreeStateMachineHandling
Martin Felis 2024-03-22 12:25:42 +01:00
parent e687c9b613
commit 3a7f470acf
2 changed files with 15 additions and 2 deletions

View File

@ -42,11 +42,24 @@ struct BlendTreeResource {
std::vector<AnimNodeResource> m_nodes; std::vector<AnimNodeResource> m_nodes;
std::vector<BlendTreeConnectionResource> m_connections; std::vector<BlendTreeConnectionResource> m_connections;
~BlendTreeResource() { CleanupNodes();
}
void Reset() { void Reset() {
m_nodes.clear(); CleanupNodes();
m_connections.clear(); m_connections.clear();
} }
void CleanupNodes() {
for (AnimNodeResource& node_resource : m_nodes) {
delete node_resource.m_anim_node;
delete node_resource.m_socket_accessor;
}
m_nodes.clear();
}
void InitGraphConnectors() { void InitGraphConnectors() {
m_nodes.push_back(AnimNodeResourceFactory("BlendTree")); m_nodes.push_back(AnimNodeResourceFactory("BlendTree"));
m_nodes[0].m_name = "Outputs"; m_nodes[0].m_name = "Outputs";

View File

@ -413,7 +413,7 @@ TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
AnimGraphResource graph_resource_loaded; AnimGraphResource graph_resource_loaded;
graph_resource_loaded.LoadFromFile(filename); graph_resource_loaded.LoadFromFile(filename);
BlendTreeResource graph_blend_tree_loaded = graph_resource_loaded.m_blend_tree_resource; BlendTreeResource& graph_blend_tree_loaded = graph_resource_loaded.m_blend_tree_resource;
const AnimNodeResource& graph_loaded_output_node = const AnimNodeResource& graph_loaded_output_node =
graph_blend_tree_loaded.m_nodes[0]; graph_blend_tree_loaded.m_nodes[0];