[Bf-blender-cvs] [fe79935f002] blender-v2.93-release: Fix T87401: Drop-down can apply the wrong modifier

Hans Goudey noreply at git.blender.org
Tue Apr 27 05:16:43 CEST 2021


Commit: fe79935f0021755ba133020a3414f6c29b46e9aa
Author: Hans Goudey
Date:   Mon Apr 26 22:16:12 2021 -0500
Branches: blender-v2.93-release
https://developer.blender.org/rBfe79935f0021755ba133020a3414f6c29b46e9aa

Fix T87401: Drop-down can apply the wrong modifier

The trouble was that there was a context pointer "modifier" in the
property editor context that returned the active modifier. But the
"modifier" variable was already used in many places, for pointers
that are *not* equivalent to the active modifier.

The context pointer for the active modifier was unecessary anyway.
If we need to access a context pointer for the active modifier in the
property editor then we can add it. Until then it only adds confusion.

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

M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/space_buttons/buttons_context.c

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

diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 5b2e0e36ba9..ededcbfdba8 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -157,10 +157,10 @@ bool edit_modifier_poll_generic(struct bContext *C,
                                 const bool is_liboverride_allowed);
 void edit_modifier_properties(struct wmOperatorType *ot);
 bool edit_modifier_invoke_properties(struct bContext *C, struct wmOperator *op);
-bool edit_modifier_invoke_properties_with_hover_no_active(struct bContext *C,
-                                                          struct wmOperator *op,
-                                                          const struct wmEvent *event,
-                                                          int *r_retval);
+bool edit_modifier_invoke_properties_with_hover(struct bContext *C,
+                                                struct wmOperator *op,
+                                                const struct wmEvent *event,
+                                                int *r_retval);
 
 struct ModifierData *edit_modifier_property_get(struct wmOperator *op,
                                                 struct Object *ob,
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 2c279eb64ee..49c07b28f07 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1116,20 +1116,27 @@ bool edit_modifier_invoke_properties(bContext *C, wmOperator *op)
 }
 
 /**
- * If the "modifier" property is not set,fill the modifier property with the name of the modifier
- * with a UI panel below the mouse cursor, without checking the context pointer. Used in order to
- * apply modifier operators on hover over their panels. If this checked the context pointer then it
- * would always use the active modifier, which isn't desired.
+ * If the "modifier" property is not set, fill the modifier property with the name of the modifier
+ * with a UI panel below the mouse cursor, unless a specific modifier is set with a context
+ * pointer. Used in order to apply modifier operators on hover over their panels.
  */
-bool edit_modifier_invoke_properties_with_hover_no_active(bContext *C,
-                                                          wmOperator *op,
-                                                          const wmEvent *event,
-                                                          int *r_retval)
+bool edit_modifier_invoke_properties_with_hover(bContext *C,
+                                                wmOperator *op,
+                                                const wmEvent *event,
+                                                int *r_retval)
 {
   if (RNA_struct_property_is_set(op->ptr, "modifier")) {
     return true;
   }
 
+  /* Note that the context pointer is *not* the active modifier, it is set in UI layouts. */
+  PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+  if (ctx_ptr.data != NULL) {
+    ModifierData *md = ctx_ptr.data;
+    RNA_string_set(op->ptr, "modifier", md->name);
+    return true;
+  }
+
   PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event);
   if (panel_ptr == NULL || RNA_pointer_is_null(panel_ptr)) {
     *r_retval = OPERATOR_CANCELLED;
@@ -1211,7 +1218,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
 static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_remove_exec(C, op);
   }
   return retval;
@@ -1257,7 +1264,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
 static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_move_up_exec(C, op);
   }
   return retval;
@@ -1302,7 +1309,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
 static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_move_down_exec(C, op);
   }
   return retval;
@@ -1345,7 +1352,7 @@ static int modifier_move_to_index_exec(bContext *C, wmOperator *op)
 static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_move_to_index_exec(C, op);
   }
   return retval;
@@ -1458,7 +1465,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
 static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_apply_exec(C, op);
   }
   return retval;
@@ -1502,7 +1509,7 @@ static int modifier_apply_as_shapekey_exec(bContext *C, wmOperator *op)
 static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_apply_as_shapekey_exec(C, op);
   }
   return retval;
@@ -1614,7 +1621,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
 static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_copy_exec(C, op);
   }
   return retval;
@@ -1657,7 +1664,7 @@ static int modifier_set_active_exec(bContext *C, wmOperator *op)
 static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_set_active_exec(C, op);
   }
   return retval;
@@ -1749,7 +1756,7 @@ static int modifier_copy_to_selected_exec(bContext *C, wmOperator *op)
 static int modifier_copy_to_selected_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   int retval;
-  if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
     return modifier_copy_to_selected_exec(C, op);
   }
   return retval;
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index c42e2531f25..1699e704a4d 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -981,17 +981,6 @@ int /*eContextResult*/ buttons_context(const bContext *C,
 
     return CTX_RESULT_OK;
   }
-  if (CTX_data_equals(member, "modifier")) {
-    PointerRNA *ptr = get_pointer_type(path, &RNA_Modifier);
-
-    if (ptr != NULL && !RNA_pointer_is_null(ptr)) {
-      Object *ob = (Object *)ptr->owner_id;
-      ModifierData *md = ptr->data;
-      CTX_data_pointer_set(result, &ob->id, &RNA_Modifier, md);
-      return CTX_RESULT_OK;
-    }
-    return CTX_RESULT_NO_DATA;
-  }
   if (CTX_data_equals(member, "texture_user")) {
     ButsContextTexture *ct = sbuts->texuser;



More information about the Bf-blender-cvs mailing list