Cleanup: Use destructor to delete Outliner runtime data
Simplifies and makes things safer due to proper RAII usage.
This commit is contained in:
parent
ca9a749b21
commit
82d5905e4b
|
@ -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 {
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue