Fix T101317: GPencil separate Active layer freezes blender

The error occurs only when the layer is empty.
This commit is contained in:
Antonio Vazquez 2022-09-25 12:26:48 +02:00
parent f68cfd6bb0
commit b6adca3280
Notes: blender-bot 2023-02-14 06:42:53 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #101317, GPencil: Active layer separation freezes blender if layer is empty
1 changed files with 3 additions and 1 deletions

View File

@ -5221,7 +5221,9 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
for (int slot = 1; slot <= ob_dst->totcol; slot++) {
while (slot <= ob_dst->totcol && !BKE_object_material_slot_used(ob_dst, slot)) {
ob_dst->actcol = slot;
BKE_object_material_slot_remove(bmain, ob_dst);
if (!BKE_object_material_slot_remove(bmain, ob_dst)) {
break;
}
if (actcol >= slot) {
actcol--;
}