diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-08-22 15:40:10 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-08-22 15:46:37 +0300 |
commit | 8f578150eaf494a03bed7389046e44f2bdf7d748 (patch) | |
tree | 5370042609d04907eff0a154e8a4b6ae858af182 /source/blender/blenloader | |
parent | 443586f34d3a0730c67b5d8787e519bec2af3656 (diff) |
Fix T68971: Copy As New Driver from Material node creates a bad reference.
NodeTree structures of materials and some other data blocks are
effectively node group data block objects that are contained inside
the parent block. Thus, direct references to them are only valid
while blender is running, and are lost on save.
Fix Copy As New Driver to create a reference that goes through
the owner data block, by adding a new runtime field to bNodeTree.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1e3342cef04..47fa8704df9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3477,13 +3477,15 @@ static void direct_link_node_socket(FileData *fd, bNodeSocket *sock) } /* ntree itself has been read! */ -static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) +static void direct_link_nodetree(FileData *fd, bNodeTree *ntree, ID *owner) { /* note: writing and reading goes in sync, for speed */ bNode *node; bNodeSocket *sock; bNodeLink *link; + ntree->owner = owner; + ntree->init = 0; /* to set callbacks and force setting types */ ntree->is_updating = false; ntree->typeinfo = NULL; @@ -3958,7 +3960,7 @@ static void direct_link_light(FileData *fd, Light *la) la->nodetree = newdataadr(fd, la->nodetree); if (la->nodetree) { direct_link_id(fd, &la->nodetree->id); - direct_link_nodetree(fd, la->nodetree); + direct_link_nodetree(fd, la->nodetree, &la->id); } la->preview = direct_link_preview_image(fd, la->preview); @@ -4121,7 +4123,7 @@ static void direct_link_world(FileData *fd, World *wrld) wrld->nodetree = newdataadr(fd, wrld->nodetree); if (wrld->nodetree) { direct_link_id(fd, &wrld->nodetree->id); - direct_link_nodetree(fd, wrld->nodetree); + direct_link_nodetree(fd, wrld->nodetree, &wrld->id); } wrld->preview = direct_link_preview_image(fd, wrld->preview); @@ -4421,7 +4423,7 @@ static void direct_link_texture(FileData *fd, Tex *tex) tex->nodetree = newdataadr(fd, tex->nodetree); if (tex->nodetree) { direct_link_id(fd, &tex->nodetree->id); - direct_link_nodetree(fd, tex->nodetree); + direct_link_nodetree(fd, tex->nodetree, &tex->id); } tex->preview = direct_link_preview_image(fd, tex->preview); @@ -4476,7 +4478,7 @@ static void direct_link_material(FileData *fd, Material *ma) ma->nodetree = newdataadr(fd, ma->nodetree); if (ma->nodetree) { direct_link_id(fd, &ma->nodetree->id); - direct_link_nodetree(fd, ma->nodetree); + direct_link_nodetree(fd, ma->nodetree, &ma->id); } ma->preview = direct_link_preview_image(fd, ma->preview); @@ -6907,7 +6909,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->nodetree = newdataadr(fd, sce->nodetree); if (sce->nodetree) { direct_link_id(fd, &sce->nodetree->id); - direct_link_nodetree(fd, sce->nodetree); + direct_link_nodetree(fd, sce->nodetree, &sce->id); } direct_link_view_settings(fd, &sce->view_settings); @@ -8931,7 +8933,7 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle) linestyle->nodetree = newdataadr(fd, linestyle->nodetree); if (linestyle->nodetree) { direct_link_id(fd, &linestyle->nodetree->id); - direct_link_nodetree(fd, linestyle->nodetree); + direct_link_nodetree(fd, linestyle->nodetree, &linestyle->id); } } @@ -9293,7 +9295,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta direct_link_action(fd, (bAction *)id); break; case ID_NT: - direct_link_nodetree(fd, (bNodeTree *)id); + direct_link_nodetree(fd, (bNodeTree *)id, NULL); break; case ID_BR: direct_link_brush(fd, (Brush *)id); |