diff --git a/scripts/startup/bl_operators/wm.py b/scripts/startup/bl_operators/wm.py index ba52d48f547..36507370399 100644 --- a/scripts/startup/bl_operators/wm.py +++ b/scripts/startup/bl_operators/wm.py @@ -1672,7 +1672,8 @@ class WM_OT_properties_edit(Operator): self.soft_max_float = rna_data["soft_max"] self.precision = rna_data["precision"] self.step_float = rna_data["step"] - self.subtype = rna_data["subtype"] + if rna_data["subtype"] in self.subtype_items_cb(None): + self.subtype = rna_data["subtype"] self.use_soft_limits = ( self.min_float != self.soft_min_float or self.max_float != self.soft_max_float diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index c7d0fff8072..54370669bab 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -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: { diff --git a/source/blender/editors/gpencil_legacy/gpencil_data.cc b/source/blender/editors/gpencil_legacy/gpencil_data.cc index 974ba53d4ba..056b864dc7f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_data.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_data.cc @@ -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; }