GPv3: Crash when drawing in locked or hidden layer

Cancel drawing operation when layer is locked/hidden (similar to GPv2).
Otherwise `get_editable_drawing_at` returns nullptr which results in crash
and assert hit.

Pull Request: https://projects.blender.org/blender/blender/pulls/116779
This commit is contained in:
Pratik Borhade
2024-01-08 11:18:55 +01:00
committed by Falk David
parent 4dad262dbe
commit dddf1ba32a
@@ -142,6 +142,12 @@ static int grease_pencil_stroke_invoke(bContext *C, wmOperator *op, const wmEven
const int current_frame = scene->r.cfra;
bke::greasepencil::Layer &active_layer = *grease_pencil.get_active_layer();
if (!active_layer.is_editable()) {
BKE_report(op->reports, RPT_ERROR, "Active layer is locked or hidden");
return OPERATOR_CANCELLED;
}
/* If there is no drawing at the current frame and auto-key is off, then */
if (!active_layer.has_drawing_at(current_frame) && !blender::animrig::is_autokey_on(scene)) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil frame to draw on");