From c8dcbc32c48f7659cb4b74205eb0ea35b3a6153a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 10 Jul 2025 17:01:25 +0200 Subject: [PATCH] Fix #141626: Refcount error when (un)assigning custom bone shapes Fix the ID user count when changing `posebone.custom_shape`. The code uses `reinterpret_cast(pchan->custom)` instead of `&pchan->custom->id`, as the former is `nullptr`-safe. Pull Request: https://projects.blender.org/blender/blender/pulls/141726 --- source/blender/makesrna/intern/rna_pose.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/makesrna/intern/rna_pose.cc b/source/blender/makesrna/intern/rna_pose.cc index 433a88a0f94..20bc6abb034 100644 --- a/source/blender/makesrna/intern/rna_pose.cc +++ b/source/blender/makesrna/intern/rna_pose.cc @@ -645,6 +645,7 @@ void rna_Pose_custom_shape_set(PointerRNA *ptr, PointerRNA value, struct ReportL Object *custom_shape = static_cast(value.data); if (!custom_shape) { + id_us_min(reinterpret_cast(pchan->custom)); pchan->custom = nullptr; return; } @@ -657,7 +658,9 @@ void rna_Pose_custom_shape_set(PointerRNA *ptr, PointerRNA value, struct ReportL return; } + id_us_min(reinterpret_cast(pchan->custom)); pchan->custom = custom_shape; + id_us_plus(reinterpret_cast(pchan->custom)); } bool rna_Pose_custom_shape_object_poll(PointerRNA * /*ptr*/, PointerRNA value)