From 4136ad045e9fec48e66b45999fb8ac19e325812f Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 28 Feb 2024 21:51:32 +0900 Subject: [PATCH] [Tizen] Do not call malloc during terminate There was some strange crash issue during application terminate. That crash comes at malloc.c during destruct JsonParser. So, let we just remove some potential of mallocate memory during terminate, what might not neccessary. Change-Id: I93dc70b0c069f90a94e526f7916f9c54e1565a7f Signed-off-by: Eunki, Hong --- .../internal/builder/tree-node-manipulator.cpp | 12 ++--------- .../internal/builder/tree-node-manipulator.h | 25 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/dali-toolkit/internal/builder/tree-node-manipulator.cpp b/dali-toolkit/internal/builder/tree-node-manipulator.cpp index 3f7e73e..aa23c76 100644 --- a/dali-toolkit/internal/builder/tree-node-manipulator.cpp +++ b/dali-toolkit/internal/builder/tree-node-manipulator.cpp @@ -162,17 +162,9 @@ void TreeNodeManipulator::RemoveChildren() { DALI_ASSERT_DEBUG(mNode && "Operation on NULL JSON node"); - CollectNodes collector; + DeleteNodesWithoutSelf otherDeletor(mNode); - DepthFirst(mNode, collector); - - for(CollectNodes::iterator iter = collector.nodes.begin(); iter != collector.nodes.end(); ++iter) - { - if(*iter != mNode) - { - delete *iter; - } - } + DepthFirst(mNode, otherDeletor); mNode->mFirstChild = NULL; mNode->mLastChild = NULL; diff --git a/dali-toolkit/internal/builder/tree-node-manipulator.h b/dali-toolkit/internal/builder/tree-node-manipulator.h index 0852497..f881f58 100644 --- a/dali-toolkit/internal/builder/tree-node-manipulator.h +++ b/dali-toolkit/internal/builder/tree-node-manipulator.h @@ -2,7 +2,7 @@ #define DALI_SCRIPT_TREE_NODE_MANIPULATOR_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -215,6 +215,29 @@ struct CollectNodes }; /* + * Delete nodes immediately, instead of self + */ +struct DeleteNodesWithoutSelf +{ + DeleteNodesWithoutSelf(TreeNode* self) + : mSelf(self){}; + + /* + * Call operator to add nodes to the list + */ + void operator()(TreeNode*& n) + { + DALI_ASSERT_DEBUG(n && "Operation on NULL JSON node"); + if(mSelf != n) + { + delete n; + } + } + + const TreeNode* mSelf; ///< self node what we should not remove. +}; + +/* * Depth first walk of nodes applying given operation (unary_function) */ template -- 2.7.4