Fix #112683: Removing the last Annotations layer produces a warning.
After removing the last Annotations layer, the current GPencil block needs to be freed. Pull Request: https://projects.blender.org/blender/blender/pulls/113274
This commit is contained in:
parent
2e084addb5
commit
19b112b11c
@ -2240,6 +2240,17 @@ static int animchannels_delete_exec(bContext *C, wmOperator * /*op*/)
|
||||
/* try to delete the layer's data and the layer itself */
|
||||
BKE_gpencil_layer_delete(gpd, gpl);
|
||||
ale->update = ANIM_UPDATE_DEPS;
|
||||
|
||||
/* Free Grease Pencil data block when last annotation layer is removed, see: #112683. */
|
||||
if (gpd->flag & GP_DATA_ANNOTATIONS && gpd->layers.first == nullptr) {
|
||||
BKE_gpencil_free_data(gpd, true);
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
scene->gpd = nullptr;
|
||||
|
||||
Main *bmain = CTX_data_main(C);
|
||||
BKE_id_free_us(bmain, gpd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ANIMTYPE_GREASE_PENCIL_LAYER: {
|
||||
|
@ -345,6 +345,17 @@ static int gpencil_layer_remove_exec(bContext *C, wmOperator *op)
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, nullptr);
|
||||
|
||||
/* Free Grease Pencil data block when last annotation layer is removed, see: #112683. */
|
||||
if (is_annotation && gpd->layers.first == nullptr) {
|
||||
BKE_gpencil_free_data(gpd, true);
|
||||
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, nullptr);
|
||||
*gpd_ptr = nullptr;
|
||||
|
||||
Main *bmain = CTX_data_main(C);
|
||||
BKE_id_free_us(bmain, gpd);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user