Commit: 70c56997344edc1a69d95fe209a6a61fc55605f1
Author: Antonioya
Date:   Tue Feb 12 18:14:36 2019 +0100
Branches: master
https://developer.blender.org/rB70c56997344edc1a69d95fe209a6a61fc55605f1

GP: Move to new layer did not work with autolock

When the autolock layer option was enabled, the move to new layer operator was 
not working as expected.

===================================================================

M       source/blender/editors/gpencil/gpencil_edit.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index 580480a3b46..cee259eb6e9 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1186,12 +1186,18 @@ static int gp_move_to_layer_exec(bContext *C, 
wmOperator *op)
        bGPDlayer *target_layer = NULL;
        ListBase strokes = {NULL, NULL};
        int layer_num = RNA_enum_get(op->ptr, "layer");
+       const bool use_autolock = (bool)(gpd->flag & GP_DATA_AUTOLOCK_LAYERS);
 
        if (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)) {
                BKE_report(op->reports, RPT_ERROR, "Operator not supported in 
multiframe edition");
                return OPERATOR_CANCELLED;
        }
 
+       /* if autolock enabled, disabled now */
+       if (use_autolock) {
+               gpd->flag &= ~GP_DATA_AUTOLOCK_LAYERS;
+       }
+
        /* Get layer or create new one */
        if (layer_num == -1) {
                /* Create layer */
@@ -1202,6 +1208,10 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator 
*op)
                target_layer = BLI_findlink(&gpd->layers, layer_num);
 
                if (target_layer == NULL) {
+                       /* back autolock status */
+                       if (use_autolock) {
+                               gpd->flag |= GP_DATA_AUTOLOCK_LAYERS;
+                       }
                        BKE_reportf(op->reports, RPT_ERROR, "There is no layer 
number %d", layer_num);
                        return OPERATOR_CANCELLED;
                }
@@ -1234,6 +1244,11 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator 
*op)
                                BLI_addtail(&strokes, gps);
                        }
                }
+
+               /* if new layer and autolock, lock old layer */
+               if ((layer_num == -1) && (use_autolock)) {
+                       gpl->flag |= GP_LAYER_LOCKED;
+               }
        }
        CTX_DATA_END;
 
@@ -1245,6 +1260,11 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator 
*op)
                BLI_assert((strokes.first == strokes.last) && (strokes.first == 
NULL));
        }
 
+       /* back autolock status */
+       if (use_autolock) {
+               gpd->flag |= GP_DATA_AUTOLOCK_LAYERS;
+       }
+
        /* updates */
        DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
        WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to