[Bf-blender-cvs] [49ab100] id_override_static: Some changes to RNA property/struct comparison.

Bastien Montagne noreply at git.blender.org
Mon Jan 2 12:56:31 CET 2017


Commit: 49ab1003833a387709a34745c7b9b686ad74282a
Author: Bastien Montagne
Date:   Wed Dec 7 21:32:03 2016 +0100
Branches: id_override_static
https://developer.blender.org/rB49ab1003833a387709a34745c7b9b686ad74282a

Some changes to RNA property/struct comparison.

Could very easily get into infinite loop when comparing Pointer
properties... And in any case, comparing ID pointer should be enough, no
need to dive into all ID properties!

===================================================================

M	source/blender/makesrna/intern/rna_access.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index bb839fd..c2c96f8 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7013,11 +7013,22 @@ bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, eRNAEq
 			if (!STREQ(RNA_property_identifier(prop), "rna_type")) {
 				PointerRNA propptr_a = RNA_property_pointer_get(a, prop);
 				PointerRNA propptr_b = RNA_property_pointer_get(b, prop);
-				return RNA_struct_equals(&propptr_a, &propptr_b, mode);
+				if (RNA_struct_is_ID(propptr_a.type)) {
+					/* In case this is an ID, do not compare structs!
+					 * This is a quite safe path to infinite loop.
+					 * Instead, just compare pointers themselves (we assume sub-ID struct cannot loop). */
+					return propptr_a.id.data != propptr_b.id.data;
+				}
+				else {
+					return RNA_struct_equals(&propptr_a, &propptr_b, mode);
+				}
 			}
 			break;
 		}
 
+		case PROP_COLLECTION:
+			/* TODO! for override... */
+
 		default:
 			break;
 	}
@@ -7028,7 +7039,6 @@ bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, eRNAEq
 bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, eRNAEqualsMode mode)
 {
 	CollectionPropertyIterator iter;
-//	CollectionPropertyRNA *citerprop;  /* UNUSED */
 	PropertyRNA *iterprop;
 	bool equals = true;
 
@@ -7040,7 +7050,6 @@ bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, eRNAEqualsMode mode)
 		return false;
 
 	iterprop = RNA_struct_iterator_property(a->type);
-//	citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop);  /* UNUSED */
 
 	RNA_property_collection_begin(a, iterprop, &iter);
 	for (; iter.valid; RNA_property_collection_next(&iter)) {




More information about the Bf-blender-cvs mailing list