From ce8a032ac2a3edf9fde9cdeb5a8dd42a6c5625ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 22 Mar 2024 09:52:58 +0100 Subject: [PATCH] Anim: fix bug in name uniqueness check for editbones Fix the name uniqueness check for editbones. The function can receive a "bone to ignore", which would not be properly ignored. If it was found earlier in `armature->edbo` than another bone with the same name, the name would incorrectly be marked as unique. This issue only occurred when a "bone to ignore" was passed to the uniqueness check. This never actually happens in the current code, but that's going to change soon. --- .../blender/editors/armature/armature_naming.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/armature/armature_naming.cc b/source/blender/editors/armature/armature_naming.cc index 7c4f77944c8..9f4c9c275f4 100644 --- a/source/blender/editors/armature/armature_naming.cc +++ b/source/blender/editors/armature/armature_naming.cc @@ -22,6 +22,7 @@ #include "BLI_blenlib.h" #include "BLI_ghash.h" +#include "BLI_listbase_wrapper.hh" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" @@ -53,7 +54,7 @@ #include "armature_intern.hh" -using blender::Vector; +using namespace blender; /* -------------------------------------------------------------------- */ /** \name Unique Bone Name Utility (Edit Mode) @@ -66,6 +67,18 @@ static bool editbone_unique_check(void *arg, const char *name) ListBase *lb; void *bone; } *data = static_cast(arg); + + if (data->bone) { + /* This indicates that there is a bone to ignore. This means ED_armature_ebone_find_name() + * cannot be used, as it might return the bone we should be ignoring. */ + for (EditBone *ebone : ListBaseWrapper(data->lb)) { + if (STREQ(ebone->name, name) && ebone != data->bone) { + return true; + } + } + return false; + } + EditBone *dupli = ED_armature_ebone_find_name(data->lb, name); return dupli && dupli != data->bone; }