Merge branch 'blender-v3.1-release'

This commit is contained in:
Campbell Barton 2022-03-07 21:52:24 +11:00
commit 638c0bd234
2 changed files with 34 additions and 9 deletions

View File

@ -426,13 +426,18 @@ def _template_items_change_frame(params):
# Tool System Templates
def _template_items_tool_select(params, operator, cursor_operator, *, extend):
def _template_items_tool_select(params, operator, cursor_operator, fallback, *, extend):
if params.select_mouse == 'LEFTMOUSE':
# Immediate select without quick delay.
# By default use 'PRESS' for immediate select without quick delay.
# Fallback key-maps 'CLICK' since 'PRESS' events passes through (allowing either click or drag).
#
# NOTE: When the active (non-fallback) tool uses a key-map that activates it's primary tool on drag,
# it's important that this key-map uses click and not press. Otherwise it becomes impossible to use
# the tool without selecting elements under the cursor.
return [
(operator, {"type": 'LEFTMOUSE', "value": 'PRESS'},
(operator, {"type": 'LEFTMOUSE', "value": 'CLICK' if fallback else 'PRESS'},
{"properties": [("deselect_all", True)]}),
(operator, {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
(operator, {"type": 'LEFTMOUSE', "value": 'CLICK' if fallback else 'PRESS', "shift": True},
{"properties": [(extend, True)]}),
]
else:
@ -6280,7 +6285,7 @@ def km_image_editor_tool_uv_select(params, *, fallback):
{"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
{"items": [
*([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select(
params, "uv.select", "uv.cursor_set", extend="extend")),
params, "uv.select", "uv.cursor_set", fallback, extend="extend")),
*([] if (not params.use_fallback_tool_rmb) else _template_uv_select(
type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy)),
]},
@ -6487,7 +6492,7 @@ def km_3d_view_tool_select(params, *, fallback):
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
*([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select(
params, "view3d.select", "view3d.cursor3d", extend="toggle")),
params, "view3d.select", "view3d.cursor3d", fallback, extend="toggle")),
*([] if (not params.use_fallback_tool_rmb) else _template_view3d_select(
type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy, exclude_mod="ctrl")),
]},
@ -7399,7 +7404,7 @@ def km_3d_view_tool_edit_gpencil_select(params, *, fallback):
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
*([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select(
params, "gpencil.select", "view3d.cursor3d", extend="toggle")),
params, "gpencil.select", "view3d.cursor3d", fallback, extend="toggle")),
*([] if (not params.use_fallback_tool_rmb) else _template_view3d_gpencil_select(
type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy)),
]},
@ -7537,7 +7542,7 @@ def km_3d_view_tool_sculpt_gpencil_select(params):
return (
"3D View Tool: Sculpt Gpencil, Tweak",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d", extend="toggle")},
{"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d", False, extend="toggle")},
)
@ -7577,7 +7582,7 @@ def km_sequencer_editor_tool_generic_select(params, *, fallback):
{"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
{"items": [
*([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select(
params, "sequencer.select", "sequencer.cursor_set", extend="toggle")),
params, "sequencer.select", "sequencer.cursor_set", fallback, extend="toggle")),
*([] if (not params.use_fallback_tool_rmb) else _template_sequencer_preview_select(
type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy)),

View File

@ -455,6 +455,19 @@ static bool view3d_ruler_item_mousemove(const bContext *C,
return false;
}
/**
* When the gizmo-group has been created immediately before running an operator
* to manipulate rulers, it's possible the new gizmo-group has not yet been initialized.
* in 3.0 this happened because left-click drag would both select and add a new ruler,
* significantly increasing the likelihood of this happening.
* Workaround this crash by checking the gizmo's custom-data has not been cleared.
* The key-map has also been modified not to trigger this bug, see T95591.
*/
static bool gizmo_ruler_check_for_operator(const wmGizmoGroup *gzgroup)
{
return gzgroup->customdata != NULL;
}
/** \} */
/* -------------------------------------------------------------------- */
@ -1294,6 +1307,10 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
const bool use_depth = (v3d->shading.type >= OB_SOLID);
if (!gizmo_ruler_check_for_operator(gzgroup)) {
return OPERATOR_CANCELLED;
}
/* Create new line */
RulerItem *ruler_item;
ruler_item = ruler_item_add(gzgroup);
@ -1369,6 +1386,9 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent
wmGizmoMap *gzmap = region->gizmo_map;
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
if (gzgroup) {
if (!gizmo_ruler_check_for_operator(gzgroup)) {
return OPERATOR_CANCELLED;
}
RulerInfo *ruler_info = gzgroup->customdata;
if (ruler_info->item_active) {
RulerItem *ruler_item = ruler_info->item_active;