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 committed by Philipp Oeser
parent 740b501d8b
commit 803d9f9748
Notes: blender-bot 2023-02-14 10:43:47 +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

@ -4820,7 +4820,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--;
}