diff options
author | Julian Eisel <julian@blender.org> | 2022-01-14 20:35:14 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-01-14 21:26:04 +0300 |
commit | ca9a749b21e6048845ca1401ba73c023dda68340 (patch) | |
tree | e61087aeb24201ef0be74d0a4854ab7972ffe6db /source/blender/editors/space_outliner/outliner_tree.cc | |
parent | e9a43a3b6060b57b75e42f27c288608352f000ea (diff) |
Cleanup: Use smart pointers for Outliner tree display and element types
Smart pointers should be the default choice for C++ owning pointers,
since they let you manage memory using RAII.
Also moved type factory methods into static class functions.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.cc')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 477ed88cb87..5f378a02052 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -217,7 +217,7 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree) if (element->flag & TE_FREE_NAME) { MEM_freeN((void *)element->name); } - outliner_tree_element_type_free(&element->type); + element->type = nullptr; MEM_freeN(element); } @@ -862,7 +862,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, /* New C++ based type handle. Only some support this, eventually this should replace * `TreeElement` entirely. */ - te->type = outliner_tree_element_type_create(type, *te, idv); + te->type = AbstractTreeElement::createFromType(type, *te, idv); if (te->type) { /* Element types ported to the new design are expected to have their name set at this point! */ BLI_assert(te->name != nullptr); @@ -1880,10 +1880,9 @@ void outliner_build_tree(Main *mainvar, outliner_free_tree(&space_outliner->tree); outliner_storage_cleanup(space_outliner); - outliner_tree_display_destroy(&space_outliner->runtime->tree_display); - space_outliner->runtime->tree_display = outliner_tree_display_create(space_outliner->outlinevis, - space_outliner); + space_outliner->runtime->tree_display = AbstractTreeDisplay::createFromDisplayMode( + space_outliner->outlinevis, *space_outliner); /* All tree displays should be created as sub-classes of AbstractTreeDisplay. */ BLI_assert(space_outliner->runtime->tree_display != nullptr); |