Fix T94633: Sculpt mode missing check for hidden active object

Note there is a bug in BKE_object_is_visible_in_viewport, it
returns false when the object is in local mode.

The transform operator poll should do a similar test.  That
would allow us to move the test from sculpt_brush_strok_invoke
to SCULPT_mode_poll (at the moment we cannot do this due to
the brush operator falling through to the translate keymap
item in global view3d keymap).
This commit is contained in:
Joseph Eagar 2022-07-10 23:39:45 -07:00
parent 133d398120
commit cb39058f2f
Notes: blender-bot 2024-03-04 09:22:33 +01:00
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
Referenced by issue #94633, Mode locked and crash if objects become disabled in viewport while not in object mode (fixed in 3.6, 3.3 LTS issue only)
1 changed files with 14 additions and 1 deletions

View File

@ -5499,10 +5499,23 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
struct PaintStroke *stroke;
int ignore_background_click;
int retval;
Object *ob = CTX_data_active_object(C);
/* Test that ob is visible; otherwise we won't be able to get evaluated data
* from the depsgraph. We do this here instead of SCULPT_mode_poll
* to avoid falling through to the translate operator in the
* global view3d keymap.
*
* Note: BKE_object_is_visible_in_viewport is not working here (it returns false
* if the object is in local view); instead, test for OB_HIDE_VIEWPORT directly.
*/
if (ob->visibility_flag & OB_HIDE_VIEWPORT) {
return OPERATOR_CANCELLED;
}
sculpt_brush_stroke_init(C, op);
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);