[Bf-blender-cvs] [061d76f55cb] master: Revert "Cleanup: remove public unused function."

Campbell Barton noreply at git.blender.org
Wed Jul 15 05:10:03 CEST 2020


Commit: 061d76f55cb172f9cbe133ba6a0f92ca5feb6b88
Author: Campbell Barton
Date:   Wed Jul 15 13:09:06 2020 +1000
Branches: master
https://developer.blender.org/rB061d76f55cb172f9cbe133ba6a0f92ca5feb6b88

Revert "Cleanup: remove public unused function."

This reverts commit 03c8b048a166584a72ceff08432401cd7047648c.

This commit re-introduced T76837.

While there is a comment explaining why this function is needed,
the naming of the poll function does make this confusing.
The API could be changed to avoid confusion here.

===================================================================

M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/screen/screen_ops.c

===================================================================

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 1ae8b33a03f..71b7d35908b 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -347,6 +347,7 @@ bool ED_operator_info_active(struct bContext *C);
 bool ED_operator_console_active(struct bContext *C);
 
 bool ED_operator_object_active(struct bContext *C);
+bool ED_operator_object_active_editable_ex(struct bContext *C, const Object *ob);
 bool ED_operator_object_active_editable(struct bContext *C);
 bool ED_operator_object_active_local_editable(struct bContext *C);
 bool ED_operator_object_active_editable_mesh(struct bContext *C);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 49d80bc15ee..04113f70e52 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1463,6 +1463,13 @@ static const EnumPropertyItem *object_mode_set_itemsf(bContext *C,
   return item;
 }
 
+static bool object_mode_set_poll(bContext *C)
+{
+  /* Needed as #ED_operator_object_active_editable doesn't call use 'active_object'. */
+  Object *ob = CTX_data_active_object(C);
+  return ED_operator_object_active_editable_ex(C, ob);
+}
+
 static int object_mode_set_exec(bContext *C, wmOperator *op)
 {
   const bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode");
@@ -1567,7 +1574,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = object_mode_set_exec;
-  ot->poll = ED_operator_object_active_editable;
+  ot->poll = object_mode_set_poll;
 
   /* flags */
   ot->flag = 0; /* no register/undo here, leave it to operators being called */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 1555dce8b79..b034fb186d2 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -349,7 +349,7 @@ bool ED_operator_object_active(bContext *C)
   return ((ob != NULL) && !ed_object_hidden(ob));
 }
 
-static bool operator_object_active_editable_ex(const Object *ob)
+bool ED_operator_object_active_editable_ex(bContext *UNUSED(C), const Object *ob)
 {
   return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob));
 }
@@ -357,14 +357,14 @@ static bool operator_object_active_editable_ex(const Object *ob)
 bool ED_operator_object_active_editable(bContext *C)
 {
   Object *ob = ED_object_active_context(C);
-  return operator_object_active_editable_ex(ob);
+  return ED_operator_object_active_editable_ex(C, ob);
 }
 
 /** Object must be editable and fully local (i.e. not an override). */
 bool ED_operator_object_active_local_editable(bContext *C)
 {
   Object *ob = ED_object_active_context(C);
-  return operator_object_active_editable_ex(ob) && !ID_IS_OVERRIDE_LIBRARY(ob);
+  return ED_operator_object_active_editable_ex(C, ob) && !ID_IS_OVERRIDE_LIBRARY(ob);
 }
 
 bool ED_operator_object_active_editable_mesh(bContext *C)



More information about the Bf-blender-cvs mailing list