From 47a0d9b52f32e986a8a30c2fe50a635d1574cede Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 6 Oct 2025 09:38:39 +0200 Subject: [PATCH] Fix #146529: Crash getting RNA path to scene rigid body pointcache Spawning the tooltip or changing values would cause this. Error in 28827b62f7 Above commit only considered PointCaches associated with **objects**, not taking into account scene rigid body cache. This is now added with this PR. Previously it would cast into modifiers when we actually had a scene as owner... resulting in a crash. This was only exposed by 6bf868562850 (it crashes since, was just not working properly before...). 6bf868562850 changed the data layout of `struct Object` and only by pure luck the modifiers loop was skipped, now with the new layout it is entered (but with garbage data resulting in the crash. Pull Request: https://projects.blender.org/blender/blender/pulls/146577 --- .../makesrna/intern/rna_object_force.cc | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object_force.cc b/source/blender/makesrna/intern/rna_object_force.cc index c9b588cfd0c..def328cece7 100644 --- a/source/blender/makesrna/intern/rna_object_force.cc +++ b/source/blender/makesrna/intern/rna_object_force.cc @@ -118,7 +118,7 @@ static const EnumPropertyItem empty_vortex_shape_items[] = { # include "ED_object.hh" -static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **scene) +static bool rna_Cache_get_valid_owner_ID(const PointerRNA *ptr, Object **ob, Scene **scene) { switch (GS(ptr->owner_id->name)) { case ID_OB: @@ -139,10 +139,27 @@ static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **s static std::optional rna_PointCache_path(const PointerRNA *ptr) { - ModifierData *md; - Object *ob = (Object *)ptr->owner_id; PointCache *cache = static_cast(ptr->data); + Object *ob = nullptr; + Scene *scene = nullptr; + + if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) { + return std::nullopt; + } + + /* Scene rigid body. */ + if (scene != nullptr && scene->rigidbody_world->shared != nullptr) { + if (scene->rigidbody_world->shared->pointcache == cache) { + return "rigidbody_world.point_cache"; + } + } + + if (!ob) { + return std::nullopt; + } + + ModifierData *md; for (md = static_cast(ob->modifiers.first); md; md = md->next) { const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); @@ -198,6 +215,7 @@ static std::optional rna_PointCache_path(const PointerRNA *ptr) } } } + return std::nullopt; }