diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-27 06:16:12 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-27 06:16:30 +0300 |
commit | fe79935f0021755ba133020a3414f6c29b46e9aa (patch) | |
tree | 3f5dd1bc6aca337936dd5a292f4d2f039f546b99 /source/blender/editors/object/object_modifier.c | |
parent | 51c13be8207fc5c3eb222711ad1477cbac848c4c (diff) |
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.
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 41 |
1 files changed, 24 insertions, 17 deletions
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; |