From 2e084addb542efafeb68285d6692d1062713a3dc Mon Sep 17 00:00:00 2001 From: bonj Date: Sat, 21 Oct 2023 15:03:28 +0200 Subject: [PATCH 1/2] Fix #102885: IDproperty subtype can cause Blender UI to throw exception When the subtype of a custom property is set programmatically to something that isn't in the subtype enum of this operator, attempting to edit it will throw an error. This check should avoid that, by simply not setting the subtype if it's not in the enum, resulting in a default subtype of NONE. This is the second attempt at #112582, which I broke when messing with branches. Pull Request: https://projects.blender.org/blender/blender/pulls/114003 --- scripts/startup/bl_operators/wm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/startup/bl_operators/wm.py b/scripts/startup/bl_operators/wm.py index 77e302636c6..bf71caf89d7 100644 --- a/scripts/startup/bl_operators/wm.py +++ b/scripts/startup/bl_operators/wm.py @@ -1666,7 +1666,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 From 19b112b11c79ad2a7ab1cc01d7c1595db0482933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Davidovi=C4=87?= Date: Sun, 22 Oct 2023 07:39:32 +0200 Subject: [PATCH 2/2] 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 --- .../blender/editors/animation/anim_channels_edit.cc | 11 +++++++++++ source/blender/editors/gpencil_legacy/gpencil_data.cc | 11 +++++++++++ 2 files changed, 22 insertions(+) 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 1c6eb74fb42..3159c3c0f0e 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; }