From ca74ebc96e134f361b842a6b338774a24d327c2b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 19 May 2021 17:45:47 +0200 Subject: [PATCH] IDManagement: Do not prevent sorting of linked IDs in `BKE_id_new_name_validate`. While this function should (currently) not be called on linked ID, there is no reason to treat those differently than local IDs, for the part that they have in common: needs to be properly sorted. --- source/blender/blenkernel/intern/lib_id.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 62d7c6a2d4c..c2e5006cbc1 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -1366,8 +1366,7 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint) ID *id_sorting_hint_next = id_sorting_hint->next; if (BLI_strcasecmp(id_sorting_hint->name, id->name) < 0 && - (id_sorting_hint_next == NULL || - id_sorting_hint_next->lib != id->lib || + (id_sorting_hint_next == NULL || id_sorting_hint_next->lib != id->lib || BLI_strcasecmp(id_sorting_hint_next->name, id->name) > 0)) { BLI_insertlinkafter(lb, id_sorting_hint, id); return; @@ -1375,8 +1374,7 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint) ID *id_sorting_hint_prev = id_sorting_hint->prev; if (BLI_strcasecmp(id_sorting_hint->name, id->name) > 0 && - (id_sorting_hint_prev == NULL || - id_sorting_hint_prev->lib != id->lib || + (id_sorting_hint_prev == NULL || id_sorting_hint_prev->lib != id->lib || BLI_strcasecmp(id_sorting_hint_prev->name, id->name) < 0)) { BLI_insertlinkbefore(lb, id_sorting_hint, id); return; @@ -1716,12 +1714,14 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name, ID **r_id_sorting_ */ bool BKE_id_new_name_validate(ListBase *lb, ID *id, const char *tname) { - bool result; + bool result = false; char name[MAX_ID_NAME - 2]; - /* if library, don't rename */ + /* If library, don't rename, but do ensure proper sorting. */ if (ID_IS_LINKED(id)) { - return false; + id_sort_by_name(lb, id, NULL); + + return result; } /* if no name given, use name of current ID