Fix T104121: Grease pencil clear function in python not updated in viewport

The clear functions for grease pencil data/frame/layer
was not followed by immediate update in the viewport.
Some notifiers were missing in the rna definition of these functions,
which are added in by this patch.

Reviewed By: Antonio Vazquez

Differential Revision: https://developer.blender.org/D17120
This commit is contained in:
Amélie Fondevilla 2023-01-25 17:00:10 +01:00
parent 564673b8ea
commit ef39d85d7c
Notes: blender-bot 2023-02-14 11:07:28 +01:00
Referenced by issue #104121, Clearing grease pencil data/frame/layer using python does not clear viewport
1 changed files with 12 additions and 2 deletions

View File

@ -1101,17 +1101,23 @@ static void rna_GPencil_layer_mask_remove(bGPDlayer *gpl,
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
static void rna_GPencil_frame_clear(bGPDframe *frame)
static void rna_GPencil_frame_clear(ID *id, bGPDframe *frame)
{
BKE_gpencil_free_strokes(frame);
bGPdata *gpd = (bGPdata *)id;
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
static void rna_GPencil_layer_clear(bGPDlayer *layer)
static void rna_GPencil_layer_clear(ID *id, bGPDlayer *layer)
{
BKE_gpencil_free_frames(layer);
bGPdata *gpd = (bGPdata *)id;
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@ -1119,6 +1125,8 @@ static void rna_GPencil_clear(bGPdata *gpd)
{
BKE_gpencil_free_layers(&gpd->layers);
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@ -1841,6 +1849,7 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
/* API */
func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
RNA_def_function_ui_description(func, "Remove all the grease pencil frame data");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
}
static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
@ -2304,6 +2313,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
/* Layers API */
func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
RNA_def_function_ui_description(func, "Remove all the grease pencil layer data");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
}
static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)