diff options
author | Julian Eisel <julian@blender.org> | 2022-01-14 21:04:44 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-01-14 21:26:04 +0300 |
commit | 82d5905e4b146685ad577f7bb4909535abbb6cd7 (patch) | |
tree | 11b7738644cfb5a226f18348c287978d3af58e07 /source/blender | |
parent | ca9a749b21e6048845ca1401ba73c023dda68340 (diff) |
Cleanup: Use destructor to delete Outliner runtime data
Simplifies and makes things safer due to proper RAII usage.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_intern.hh | 1 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.cc | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index bc6eedb7620..9065f7f9cc1 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -66,6 +66,7 @@ struct SpaceOutliner_Runtime { SpaceOutliner_Runtime() = default; /** Used for copying runtime data to a duplicated space. */ SpaceOutliner_Runtime(const SpaceOutliner_Runtime &); + ~SpaceOutliner_Runtime(); }; typedef enum TreeElementInsertType { diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index a8068bc9b71..ea07f1d4611 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -57,6 +57,13 @@ SpaceOutliner_Runtime::SpaceOutliner_Runtime(const SpaceOutliner_Runtime & /*oth { } +SpaceOutliner_Runtime::~SpaceOutliner_Runtime() +{ + if (treehash) { + BKE_outliner_treehash_free(treehash); + } +} + static void outliner_main_region_init(wmWindowManager *wm, ARegion *region) { ListBase *lb; @@ -366,13 +373,7 @@ static void outliner_free(SpaceLink *sl) BLI_mempool_destroy(space_outliner->treestore); } - if (space_outliner->runtime) { - space_outliner->runtime->tree_display = nullptr; - if (space_outliner->runtime->treehash) { - BKE_outliner_treehash_free(space_outliner->runtime->treehash); - } - MEM_freeN(space_outliner->runtime); - } + MEM_delete(space_outliner->runtime); } /* spacetype; init callback */ |