Depsgraph: Fix crash with copy on write when scene has legacy bases
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 20 Jul 2017 11:25:52 +0000 (13:25 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 20 Jul 2017 11:27:34 +0000 (13:27 +0200)
The remapping code was creating plkaceholders for objects coming from legacy
bases, but since those objects were never created by dependency graph (since
they are supposed to be ignored) the copy on write relations creation was
confused.

Now we do some special trickery to clear legacy bases on copy on write.

source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

index f895563dd997900f9138809a916d50c2e81be78c..da06cfdf330adbdb285d17ed590524a1129d2875 100644 (file)
@@ -110,7 +110,18 @@ void nested_id_hack_discard_pointers(ID *id_cow)
                SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree)
                SPECIAL_CASE(ID_LA, Lamp, nodetree)
                SPECIAL_CASE(ID_MA, Material, nodetree)
+#if 0
                SPECIAL_CASE(ID_SCE, Scene, nodetree)
+#else
+               case ID_SCE:
+               {
+                       Scene *scene_cow = (Scene *)id_cow;
+                       scene_cow->nodetree = NULL;
+                       scene_cow->base.first = NULL;
+                       scene_cow->base.last = NULL;
+                       break;
+               }
+#endif
                SPECIAL_CASE(ID_TE, Tex, nodetree)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
@@ -142,7 +153,18 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
                SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree, linestyle)
                SPECIAL_CASE(ID_LA, Lamp, nodetree, lamp)
                SPECIAL_CASE(ID_MA, Material, nodetree, material)
+#if 0
                SPECIAL_CASE(ID_SCE, Scene, nodetree, scene)
+#else
+               case ID_SCE:
+               {
+                       storage->scene = *(Scene *)id;
+                       storage->scene.nodetree = NULL;
+                       storage->scene.base.first = NULL;
+                       storage->scene.base.last = NULL;
+                       return &storage->scene.id;
+               }
+#endif
                SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
                SPECIAL_CASE(ID_WO, World, nodetree, world)