From 5b88ab25bd83804af007136a1c7b9d8a9d1c1514 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Tue, 31 Mar 2020 18:54:41 +0200 Subject: Fix T75219: Move to New Layer not working This was an old design problem. --- source/blender/editors/gpencil/gpencil_edit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/gpencil') diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index dc7bbfb99fa..91169b34e34 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1569,7 +1569,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) } /* Try to get layer */ - target_layer = BLI_findlink(&gpd->layers, layer_num); + if (layer_num > -1) { + target_layer = BLI_findlink(&gpd->layers, layer_num); + } + else { + /* Create a new layer. */ + target_layer = BKE_gpencil_layer_addnew(gpd, "GP_Layer", true); + } if (target_layer == NULL) { /* back autolock status */ @@ -1655,7 +1661,8 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* GPencil layer to use. */ - ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX); + ot->prop = RNA_def_int( + ot->srna, "layer", 0, -1, INT_MAX, "Grease Pencil Layer", "", -1, INT_MAX); RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -- cgit v1.2.3