Fix #36850, Material Node Editor Crash Always.
authorLukas Toenne <lukas.toenne@googlemail.com>
Tue, 1 Oct 2013 08:18:16 +0000 (08:18 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Tue, 1 Oct 2013 08:18:16 +0000 (08:18 +0000)
This problem was introduced with pynodes merge in r55373. It's caused by missing localization of node groups in shaders in cases where GLSL + node previews causes threading conflicts. I'm not quite sure why
we didn't do this before, but now all node groups also get localized recursively.

source/blender/blenkernel/intern/node.c

index 2305c0696af9599816286d9bb415b30d5a2fb07f..7cdc2ce856a97d5b70d3be9db3d8afc1613cb497 100644 (file)
@@ -1933,7 +1933,13 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
                 * Note: previews are not copied here.
                 */
                ltree = ntreeCopyTree_internal(ntree, FALSE, FALSE, FALSE);
-       
+               
+               for (node = ltree->nodes.first; node; node = node->next) {
+                       if (node->type == NODE_GROUP && node->id) {
+                               node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
+                       }
+               }
+               
                if (adt) {
                        AnimData *ladt = BKE_animdata_from_id(&ltree->id);
        
@@ -1978,9 +1984,23 @@ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
 /* we have to assume the editor already changed completely */
 void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
 {
-       if (localtree && ntree) {
-               if (ntree->typeinfo->local_merge)
-                       ntree->typeinfo->local_merge(localtree, ntree);
+       bNode *node;
+       
+       if (localtree) {
+               if (ntree) {
+                       if (ntree->typeinfo->local_merge)
+                               ntree->typeinfo->local_merge(localtree, ntree);
+               }
+               
+               for (node = localtree->nodes.first; node; node = node->next) {
+                       if (node->type == NODE_GROUP && node->id) {
+                               bNodeTree *localgroup = (bNodeTree *)node->id;
+                               /* not passing original node tree for node group merge,
+                                * because there may be multiple instances using the same group tree.
+                                */
+                               ntreeLocalMerge(localgroup, NULL);
+                       }
+               }
                
                ntreeFreeTree_ex(localtree, FALSE);
                MEM_freeN(localtree);