From b73d3b80fdcb7244637d6d2a1cd83719b91c35af Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 3 Feb 2022 17:36:05 -0600 Subject: Fix T94334: Area close operator crash in 3D view menu This fixes the crash by removing the `do_view3d_header_buttons` handler. The code can work at a higher level here, using the operator for setting the select mode, which makes this patch a cleanup as well. The operator now has a description callback to add the custom description used for the behavior in its invoke method. Differential Revision: https://developer.blender.org/D13660 --- source/blender/editors/mesh/editmesh_select.c | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/blender/editors/mesh/editmesh_select.c') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7e05209f79e..6b2d56322fc 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -32,6 +32,7 @@ #include "BLI_math.h" #include "BLI_math_bits.h" #include "BLI_rand.h" +#include "BLI_string.h" #include "BLI_utildefines_stack.h" #include "BKE_context.h" @@ -55,6 +56,8 @@ #include "ED_transform.h" #include "ED_view3d.h" +#include "BLT_translation.h" + #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -1389,6 +1392,36 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e return edbm_select_mode_exec(C, op); } +static char *edbm_select_mode_get_description(struct bContext *UNUSED(C), + struct wmOperatorType *UNUSED(op), + struct PointerRNA *values) +{ + const int type = RNA_enum_get(values, "type"); + + /* Because the special behavior for shift and ctrl click depend on user input, they may be + * incorrect if the operator is used from a script or from a special button. So only return the + * specialized descriptions if only the "type" is set, which conveys that the operator is meant + * to be used with the logic in the `invoke` method. */ + if (RNA_struct_property_is_set(values, "type") && + !RNA_struct_property_is_set(values, "use_extend") && + !RNA_struct_property_is_set(values, "use_expand") && + !RNA_struct_property_is_set(values, "action")) + switch (type) { + case SCE_SELECT_VERTEX: + return BLI_strdup( + N_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection")); + case SCE_SELECT_EDGE: + return BLI_strdup( + N_("Edge select - Shift-Click for multiple modes, " + "Ctrl-Click expands/contracts selection depending on the current mode")); + case SCE_SELECT_FACE: + return BLI_strdup( + N_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection")); + } + + return NULL; +} + void MESH_OT_select_mode(wmOperatorType *ot) { PropertyRNA *prop; @@ -1409,6 +1442,7 @@ void MESH_OT_select_mode(wmOperatorType *ot) ot->invoke = edbm_select_mode_invoke; ot->exec = edbm_select_mode_exec; ot->poll = ED_operator_editmesh; + ot->get_description = edbm_select_mode_get_description; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -- cgit v1.2.3