[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36909] trunk/blender/source/blender/ makesrna/intern/rna_sequencer.c: BUGFIX: Sequencer strips. elements was broken when strip was trimmed (personal bug report, no number)

Dalai Felinto dfelinto at gmail.com
Thu May 26 11:20:30 CEST 2011


Revision: 36909
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36909
Author:   dfelinto
Date:     2011-05-26 09:20:30 +0000 (Thu, 26 May 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_sequencer.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2011-05-26 09:08:37 UTC (rev 36908)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2011-05-26 09:20:30 UTC (rev 36909)
@@ -107,6 +107,23 @@
 }
 
 /* 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 @@
 	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 @@
 	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", "");




More information about the Bf-blender-cvs mailing list