PyAPI: raise an exception when removing an AOV which is not found
This is in keeping with how other remove functions behave.
This commit is contained in:
@@ -2514,9 +2514,8 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer)
|
||||
|
||||
void BKE_view_layer_remove_aov(ViewLayer *view_layer, ViewLayerAOV *aov)
|
||||
{
|
||||
if (aov == nullptr || BLI_findindex(&view_layer->aovs, aov) == -1) {
|
||||
return;
|
||||
}
|
||||
BLI_assert(BLI_findindex(&view_layer->aovs, aov) != -1);
|
||||
BLI_assert(aov != nullptr);
|
||||
if (view_layer->active_aov == aov) {
|
||||
if (aov->next) {
|
||||
viewlayer_aov_active_set(view_layer, aov->next);
|
||||
|
||||
@@ -201,6 +201,17 @@ static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr)
|
||||
return PointerRNA_NULL;
|
||||
}
|
||||
|
||||
static void rna_ViewLayer_remove_aov(struct ViewLayer *view_layer,
|
||||
ReportList *reports,
|
||||
struct ViewLayerAOV *aov)
|
||||
{
|
||||
if (BLI_findindex(&view_layer->aovs, aov) == -1) {
|
||||
BKE_reportf(reports, RPT_ERROR, "AOV not found in view-layer '%s'", view_layer->name);
|
||||
return;
|
||||
}
|
||||
BKE_view_layer_remove_aov(view_layer, aov);
|
||||
}
|
||||
|
||||
static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
ViewLayer *view_layer = (ViewLayer *)ptr->data;
|
||||
|
||||
@@ -4281,7 +4281,7 @@ static void rna_def_view_layer_eevee(BlenderRNA *brna)
|
||||
static void rna_def_view_layer_aovs(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
/* PropertyRNA *prop; */
|
||||
// PropertyRNA *prop;
|
||||
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
@@ -4295,9 +4295,11 @@ static void rna_def_view_layer_aovs(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
parm = RNA_def_pointer(func, "aov", "AOV", "", "Newly created AOV");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func = RNA_def_function(srna, "remove", "BKE_view_layer_remove_aov");
|
||||
/* Defined in `rna_layer.c`. */
|
||||
func = RNA_def_function(srna, "remove", "rna_ViewLayer_remove_aov");
|
||||
parm = RNA_def_pointer(func, "aov", "AOV", "", "AOV to remove");
|
||||
RNA_def_function_ui_description(func, "Remove an AOV");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user