Fix T94109: 3d cursor crash when using shortcut

Operator was erroneously starting edge_slide operation.

Revert part of the changes in rB3fab16fe8eb4 as obedit_type was being
confused with object_mode.
This commit is contained in:
Germano Cavalcante 2021-12-16 13:45:27 -03:00
parent 0624fad0f3
commit 9765ddf4eb
Notes: blender-bot 2023-04-04 07:45:26 +02:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #94109, 3d cursor crash when using shortcut
Referenced by issue #93479, 3.0 Potential candidates for corrective releases
2 changed files with 15 additions and 5 deletions

View File

@ -214,7 +214,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->flag = 0;
if (obact && ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) {
if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) &&
ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) {
t->obedit_type = obact->type;
}
else {

View File

@ -499,7 +499,9 @@ void applySnapping(TransInfo *t, float *vec)
/* Time base quirky code to go around find-nearest slowness. */
/* TODO: add exception for object mode, no need to slow it down then. */
if (current - t->tsnap.last >= 0.01) {
t->tsnap.calcSnap(t, vec);
if (t->tsnap.calcSnap) {
t->tsnap.calcSnap(t, vec);
}
if (t->tsnap.targetSnap) {
t->tsnap.targetSnap(t);
}
@ -783,8 +785,15 @@ static void setSnappingCallback(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
t->tsnap.calcSnap = snap_calc_view3d_fn;
}
else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
t->tsnap.calcSnap = snap_calc_uv_fn;
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->area->spacedata.first;
Object *obact = t->view_layer->basact ? t->view_layer->basact->object : NULL;
const bool is_uv_editor = sima->mode == SI_MODE_UV;
const bool has_edit_object = obact && BKE_object_is_in_editmode(obact);
if (is_uv_editor && has_edit_object) {
t->tsnap.calcSnap = snap_calc_uv_fn;
}
}
else if (t->spacetype == SPACE_NODE) {
t->tsnap.calcSnap = snap_calc_node_fn;
@ -959,7 +968,7 @@ static void snap_calc_view3d_fn(TransInfo *t, float *UNUSED(vec))
static void snap_calc_uv_fn(TransInfo *t, float *UNUSED(vec))
{
BLI_assert(t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH);
BLI_assert(t->spacetype == SPACE_IMAGE);
if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) {
float co[2];