all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
This commit is contained in:
@@ -308,12 +308,18 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor
|
||||
return seq;
|
||||
}
|
||||
|
||||
static void rna_Sequences_remove(ID *id, Editing *ed, Sequence *seq)
|
||||
static void rna_Sequences_remove(ID *id, Editing *ed, ReportList *reports, PointerRNA *seq_ptr)
|
||||
{
|
||||
Sequence *seq = seq_ptr->data;
|
||||
Scene *scene = (Scene *)id;
|
||||
|
||||
BLI_remlink(&ed->seqbase, seq);
|
||||
if (BLI_remlink_safe(&ed->seqbase, seq) == FALSE) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Sequence '%s' not in scene '%s'", seq->name + 2, scene->id.name + 2);
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_sequence_free(scene, seq);
|
||||
RNA_POINTER_INVALIDATE(seq_ptr);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
|
||||
}
|
||||
@@ -579,10 +585,11 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
||||
|
||||
func = RNA_def_function(srna, "remove", "rna_Sequences_remove");
|
||||
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
|
||||
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a Sequence");
|
||||
parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Sequence to remove");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
|
||||
RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user