From ea19f154004cb28b684c70be8b937e0056c715dc Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 26 May 2011 09:20:30 +0000 Subject: [PATCH] BUGFIX: Sequencer strips.elements was broken when strip was trimmed (personal bug report, no number) When trimmed the seq->len was being reduced from the offsets (initial and final). This was the length passed to the elements. This had two problems: 1) it would not allow you to change the elements not visible (although you likely want to change them as well). 2) the element[0] was always the seq->strips[0].stripdata[0], regardless of the initial trim. Anyhoo it's all working now. Thanks Campbell for helping out with this one. --- .../blender/makesrna/intern/rna_sequencer.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 90ae95894b0..6d4e9bb476c 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -107,6 +107,23 @@ static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *it } /* internal use */ +static int rna_SequenceEditor_elements_length(PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + + /* Hack? copied from sequencer.c::reload_sequence_new_file() */ + size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + + /* the problem with seq->strip->len and seq->len is that it's discounted from the offset (hard cut trim) */ + return (int) olen; +} + +static void rna_SequenceEditor_elements_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + rna_iterator_array_begin(iter, (void*)seq->strip->stripdata, sizeof(StripElem), rna_SequenceEditor_elements_length(ptr), 0, NULL); +} + static void rna_Sequence_frame_change_update(Scene *scene, Sequence *seq) { Editing *ed= seq_give_editing(scene, FALSE); @@ -1222,9 +1239,10 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", "strip->len"); + RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); RNA_def_property_struct_type(prop, "SequenceElement"); RNA_def_property_ui_text(prop, "Elements", ""); + RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_elements_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_SequenceEditor_elements_length", 0, 0); rna_def_filter_video(srna); rna_def_proxy(srna); @@ -1291,9 +1309,10 @@ static void rna_def_movie(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", "strip->len"); + RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); RNA_def_property_struct_type(prop, "SequenceElement"); RNA_def_property_ui_text(prop, "Elements", ""); + RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_elements_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_SequenceEditor_elements_length", 0, 0); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "File", "");