From 8da7ab11cf63d36577b5bd1e96bae637b0bd464c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 May 2020 16:10:21 +0200 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/scene.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f7c018edbd8..72d85f596ec 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -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); }