diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-02 13:41:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-02 13:41:26 +0400 |
commit | a31449edaddc1be80676c77babf079a9f137c42d (patch) | |
tree | 30bf1759a51f5def43dc000d6af7112642404770 /source/blender/makesrna/intern/rna_sequencer_api.c | |
parent | 2944d42c262d9d4459e356dc8b8fbad1c53c2054 (diff) |
all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_sequencer_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer_api.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index f51b3901f4f..8ddb9d0a7e7 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -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); } |