Fix T76053: Rigid Body properties disappears after deleting rigid body constraint object and undoing.

Since we re-use same addresses of IDs with newly read data, and never
remap old IDs to 'proper' 'old' ID pointers, it implies that old IDs
being deleted will have many ID pointers to new, valid data that we want
to keep.

In general anyway, code from IDTypeInfo (i.e. low-level ID management
code) should never do anything outside of its own ID scope, we cannot
guarantee that given ID is in fully valid state regarding its relations
to other data-blocks.
This commit is contained in:
Bastien Montagne 2020-05-12 16:10:21 +02:00
parent 08b4c9a815
commit 8da7ab11cf
Notes: blender-bot 2023-09-08 04:55:43 +02:00
Referenced by issue #76053, Rigid Body properties disappears after deleting rigid body constraint object and undoing
1 changed files with 5 additions and 0 deletions

View File

@ -346,6 +346,11 @@ static void scene_free_data(ID *id)
}
if (scene->rigidbody_world) {
/* Prevent rigidbody freeing code to follow other IDs pointers, this should never be allowed
* nor necessary from here, and with new undo code, those pointers may be fully invalid or
* worse, pointing to data actually belonging to new BMain! */
scene->rigidbody_world->constraints = NULL;
scene->rigidbody_world->group = NULL;
BKE_rigidbody_free_world(scene);
}