Fix crash in do-versions after recent changes
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 11 Dec 2018 11:44:29 +0000 (12:44 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 11 Dec 2018 11:44:29 +0000 (12:44 +0100)
No one can simply go into a datablock before it was linked.

source/blender/blenloader/intern/versioning_280.c

index abf7c280996cd13e8a54fb735106ee7374937d6b..237e1387a4ee9a9c68f6b932c69a979b0efd60b4 100644 (file)
@@ -917,6 +917,20 @@ void do_versions_after_linking_280(Main *bmain)
                }
                BKE_paint_toolslots_init_from_main(bmain);
        }
                }
                BKE_paint_toolslots_init_from_main(bmain);
        }
+
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) {
+               /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+                       RigidBodyWorld *rbw = scene->rigidbody_world;
+
+                       if (rbw == NULL) {
+                               continue;
+                       }
+
+                       BKE_rigidbody_objects_collection_validate(scene, rbw);
+                       BKE_rigidbody_constraints_collection_validate(scene, rbw);
+               }
+       }
 }
 
 /* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already.
 }
 
 /* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already.
@@ -2489,18 +2503,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
                                dir[0] = -dir[0];
                        }
                }
                                dir[0] = -dir[0];
                        }
                }
-
-               /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */
-               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
-                       RigidBodyWorld *rbw = scene->rigidbody_world;
-
-                       if (rbw == NULL) {
-                               continue;
-                       }
-
-                       BKE_rigidbody_objects_collection_validate(scene, rbw);
-                       BKE_rigidbody_constraints_collection_validate(scene, rbw);
-               }
        }
 
        if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {
        }
 
        if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {