Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2021-01-15 21:01:57 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2021-01-18 17:00:37 +0300
commit1c2b2037956bf1d46a10842a4b503d20714bdcf2 (patch)
tree8c8a61cc26ced33d61f642c4e9ca2aedea839e2f /source/blender/makesrna/intern/rna_pose.c
parentb4530deec478e1982156a2a76bd4bdadaf651fb3 (diff)
Fix T84600: prevent bone groups operators on proxies and library
overrides Editing bone groups is not supported on proxies/overrides [changes a re lost on file reload], need to do proper polling (and also prevent this from rna) for: - adding bone groups - removing bone groups - renaming bone groups - setting bone groups colors Previously, this was hinted at by setting the layout inactive, with preoper polls, this is now not needed anymore. note: Selection of bone groups actually makes sense here and is supported, so this is not prevented in this patch, but UI wise this is not nice in the override case, because one cannot set an active_index (aka select) in the UI list. Maniphest Tasks: T84600 Differential Revision: https://developer.blender.org/D10131
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 7f98ae47c6f..cd3e4a09fc3 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -138,8 +138,22 @@ static char *rna_PoseBone_path(PointerRNA *ptr)
/* Bone groups only. */
-static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name)
+static bool rna_bone_group_poll(Object *ob, ReportList *reports)
{
+ if ((ob->proxy != NULL) || (ob->proxy_group != NULL) || ID_IS_OVERRIDE_LIBRARY(ob)) {
+ BKE_report(reports, RPT_ERROR, "Cannot edit bonegroups for proxies or library overrides");
+ return false;
+ }
+
+ return true;
+}
+
+static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, ReportList *reports, const char *name)
+{
+ if (!rna_bone_group_poll((Object *)id, reports)) {
+ return NULL;
+ }
+
bActionGroup *grp = BKE_pose_add_group(pose, name);
WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_ADDED, id);
return grp;
@@ -147,6 +161,10 @@ static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name)
static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, PointerRNA *grp_ptr)
{
+ if (!rna_bone_group_poll((Object *)id, reports)) {
+ return;
+ }
+
bActionGroup *grp = grp_ptr->data;
const int grp_idx = BLI_findindex(&pose->agroups, grp);
@@ -163,6 +181,11 @@ static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, Poin
void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
{
+ Object *ob = (Object *)ptr->owner_id;
+ if (!rna_bone_group_poll(ob, NULL)) {
+ return;
+ }
+
bActionGroup *grp = ptr->data;
/* ensure only valid values get set */
@@ -184,6 +207,10 @@ bool rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr)
static void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object *)ptr->owner_id;
+ if (!rna_bone_group_poll(ob, NULL)) {
+ return;
+ }
+
bActionGroup *agrp = ptr->data;
/* copy the new name into the name slot */
@@ -1619,7 +1646,7 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new", "rna_bone_group_new");
RNA_def_function_ui_description(func, "Add a new bone group to the object");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID); /* ID needed for refresh */
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); /* ID needed for refresh */
RNA_def_string(func, "name", "Group", MAX_NAME, "", "Name of the new group");
/* return type */
parm = RNA_def_pointer(func, "group", "BoneGroup", "", "New bone group");