From 2eeec49640b3df3f975d947936998cf05443424a Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 2 Mar 2023 09:52:35 +0100 Subject: [PATCH] Fix #105339: grease pencil selection can toggle object selection Grease Pencil (when not in object mode) implements its own selection opertor. This operator (`gpencil.select`) returns `OPERATOR_PASS_THROUGH`, then falls though to `view3d.select` which can toggle object selection (when using shift-click picking). Removing `OPERATOR_PASS_THROUGH` would fix the object toggling, but this was added in 62c73db73415 with good reason (the tweak tool would not work then). Now prevent `view3d.select` from acting on Grease Pencil (when not in object mode). NOTE: longer term we could have grease pencil use view3d.select to avoid having to add these awkward exceptions Pull Request #105342 --- source/blender/editors/space_view3d/view3d_select.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 0d76c1bc7f8..efe003c8db9 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -2992,6 +2992,15 @@ static int view3d_select_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); + if (obact && obact->type == OB_GPENCIL && GPENCIL_ANY_MODE((bGPdata *)obact->data)) { + /* Prevent acting on Grease Pencil (when not in object mode), it implements its own selection + * operator in other modes. We might still fall trough to here (because that operator uses + * OPERATOR_PASS_THROUGH to make tweak work) but if we dont stop here code below assumes we are + * in object mode it might falsely toggle object selection. Alternatively, this could be put in + * the poll funtion instead. */ + return OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED; + } + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; ED_view3d_viewcontext_init(C, &vc, depsgraph);