[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34276] trunk/blender/source/blender/ makesrna/intern: comment array/collection skip(), since there was some confusion in this area which caused bugs on index lookups .

Campbell Barton ideasman42 at gmail.com
Wed Jan 12 07:16:15 CET 2011


Revision: 34276
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34276
Author:   campbellbarton
Date:     2011-01-12 06:16:15 +0000 (Wed, 12 Jan 2011)
Log Message:
-----------
comment array/collection skip(), since there was some confusion in this area which caused bugs on index lookups.

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

Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c	2011-01-12 06:01:07 UTC (rev 34275)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c	2011-01-12 06:16:15 UTC (rev 34276)
@@ -948,6 +948,8 @@
 
 static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc, char *nextfunc)
 {
+	/* note on indicies, this is for external functions and ignores skipped values.
+	 * so the the index can only be checked against the length when there is no 'skip' funcion. */
 	char *func;
 
 	if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
@@ -984,9 +986,9 @@
 		fprintf(f, "		ArrayIterator *internal= iter.internal;\n");
 		fprintf(f, "		if(index < 0 || index >= internal->length) {\n");
 		fprintf(f, "#ifdef __GNUC__\n");
-		fprintf(f, "			printf(\"Array iterator out of range: %%s (index %%d range %%d)\\n\", __func__, index, internal->length);  \n");
+		fprintf(f, "			printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, index);\n");
 		fprintf(f, "#else\n");
-		fprintf(f, "			printf(\"Array iterator out of range: (index %%d range %%d)\\n\", index, internal->length);  \n");
+		fprintf(f, "			printf(\"Array iterator out of range: (index %%d)\\n\", index);\n");
 		fprintf(f, "#endif\n");
 		fprintf(f, "		}\n");
 		fprintf(f, "		else if(internal->skip) {\n");

Modified: trunk/blender/source/blender/makesrna/intern/rna_internal.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_internal.h	2011-01-12 06:01:07 UTC (rev 34275)
+++ trunk/blender/source/blender/makesrna/intern/rna_internal.h	2011-01-12 06:16:15 UTC (rev 34276)
@@ -321,10 +321,15 @@
 
 typedef struct ArrayIterator {
 	char *ptr;
-	char *endptr;
+	char *endptr;	/* past the last valid pointer, only for comparisons, ignores skipped values */
 	void *free_ptr; /* will be free'd if set */
 	int itemsize;
+
+	/* array length with no skip functins applied, take care not to compare against index from animsys or python indicies */
 	int length;
+
+	/* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
+	 * this changes indicies so quick array index lookups are not possible when skip function is used. */
 	IteratorSkipFunc skip;
 } ArrayIterator;
 




More information about the Bf-blender-cvs mailing list