Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/node.c')
-rw-r--r--source/blender/blenkernel/intern/node.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 5d3994068ec..ad90c0fe82e 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2322,14 +2322,14 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
/* trees are created as local trees for compositor, material or texture nodes,
* node groups and other tree types are created as library data.
*/
- if (bmain) {
- ntree = BKE_libblock_alloc(bmain, ID_NT, name, 0);
+ const bool is_embedded = (bmain == NULL);
+ int flag = 0;
+ if (is_embedded) {
+ flag |= LIB_ID_CREATE_NO_MAIN;
}
- else {
- ntree = MEM_callocN(sizeof(bNodeTree), "new node tree");
+ ntree = BKE_libblock_alloc(bmain, ID_NT, name, flag);
+ if (is_embedded) {
ntree->id.flag |= LIB_EMBEDDED_DATA;
- *((short *)ntree->id.name) = ID_NT;
- BLI_strncpy(ntree->id.name + 2, name, sizeof(ntree->id.name));
}
/* Types are fully initialized at this point,