Fix (studio-reported) RNA allowing to rename linked IDs.
There is no reason to allow this currently, and the underlying code is not designed to support it right now. Kept liboverrides IDs names editable though through RNA API, think this can be valuable for advanced processing or debugging.
This commit is contained in:
@@ -213,6 +213,8 @@ const IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = {
|
||||
# include "BLI_listbase.h"
|
||||
# include "BLI_math_base.h"
|
||||
|
||||
# include "BLT_translation.h"
|
||||
|
||||
# include "BLO_readfile.h"
|
||||
|
||||
# include "BKE_anim_data.h"
|
||||
@@ -283,9 +285,11 @@ int rna_ID_name_length(PointerRNA *ptr)
|
||||
void rna_ID_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
ID *id = (ID *)ptr->data;
|
||||
BLI_assert(BKE_id_is_in_global_main(id));
|
||||
BLI_assert(!ID_IS_LINKED(id));
|
||||
|
||||
BKE_main_namemap_remove_name(G_MAIN, id, id->name + 2);
|
||||
BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2);
|
||||
BLI_assert(BKE_id_is_in_global_main(id));
|
||||
BKE_libblock_ensure_unique_name(G_MAIN, id);
|
||||
|
||||
if (GS(id->name) == ID_OB) {
|
||||
@@ -296,17 +300,33 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
|
||||
}
|
||||
}
|
||||
|
||||
static int rna_ID_name_editable(PointerRNA *ptr, const char ** /*r_info*/)
|
||||
static int rna_ID_name_editable(PointerRNA *ptr, const char **r_info)
|
||||
{
|
||||
ID *id = (ID *)ptr->data;
|
||||
|
||||
/* NOTE: For the time being, allow rename of local liboverrides from the RNA API.
|
||||
* While this is not allowed from the UI, this should work with modern liboverride code,
|
||||
* and could be useful in some cases. */
|
||||
if (ID_IS_LINKED(id)) {
|
||||
if (r_info) {
|
||||
*r_info = N_("Linked data-blocks cannot be renamed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (GS(id->name) == ID_VF) {
|
||||
VFont *vfont = (VFont *)id;
|
||||
if (BKE_vfont_is_builtin(vfont)) {
|
||||
if (r_info) {
|
||||
*r_info = N_("Built-in fonts cannot be renamed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (!BKE_id_is_in_global_main(id)) {
|
||||
if (r_info) {
|
||||
*r_info = N_("Datablocks not in global Main data-base cannot be renamed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user