Attempt to sanitize node tree deletion

Make it explicit when freeing node tree which is owned by other
ID or when freeing node tree which is outside of a bmain.
This commit is contained in:
2018-12-14 15:20:33 +01:00
parent 1e18efa1df
commit e67f7e922c
11 changed files with 31 additions and 18 deletions

View File

@@ -1870,8 +1870,24 @@ void ntreeFreeTree(bNodeTree *ntree)
if (ntree->duplilock)
BLI_mutex_free(ntree->duplilock);
/* if ntree is not part of library, free the libblock data explicitly */
if (ntree->id.tag & LIB_TAG_NO_MAIN) {
if (ntree->id.tag & LIB_TAG_LOCALIZED) {
BKE_libblock_free_data(&ntree->id, true);
}
}
void ntreeFreeNestedTree(bNodeTree *ntree)
{
ntreeFreeTree(ntree);
BKE_libblock_free_data(&ntree->id, true);
}
void ntreeFreeLocalTree(bNodeTree *ntree)
{
if (ntree->id.tag & LIB_TAG_LOCALIZED) {
ntreeFreeTree(ntree);
}
else {
ntreeFreeTree(ntree);
BKE_libblock_free_data(&ntree->id, true);
}
}