[Bf-blender-cvs] [3fdbd78a6b5] blender2.8: Layer / IDProperty: Prevent previously created demo files from crash

Dalai Felinto noreply at git.blender.org
Thu Mar 30 18:53:54 CEST 2017


Commit: 3fdbd78a6b5f271a8022f01ddca649ef16cf5516
Author: Dalai Felinto
Date:   Thu Mar 30 18:53:46 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB3fdbd78a6b5f271a8022f01ddca649ef16cf5516

Layer / IDProperty: Prevent previously created demo files from crash

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

M	source/blender/blenloader/intern/versioning_280.c

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

diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 55d88240100..d416f4faae4 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -212,6 +212,25 @@ void do_versions_after_linking_280(Main *main)
 	}
 }
 
+static void do_version_layer_collections_idproperties(ListBase *lb)
+{
+	IDPropertyTemplate val = {0};
+	for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+		lc->properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
+		BKE_layer_collection_engine_settings_create(lc->properties);
+
+		/* No overrides at first */
+		for (IDProperty *prop = lc->properties->data.group.first; prop; prop = prop->next) {
+			while (prop->data.group.first) {
+				IDP_FreeFromGroup(prop, prop->data.group.first);
+			}
+		}
+
+		/* Do it recursively */
+		do_version_layer_collections_idproperties(&lc->layer_collections);
+	}
+}
+
 void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 {
 	if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
@@ -237,5 +256,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 				ob->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
 			}
 		}
+
+		if (DNA_struct_elem_find(fd->filesdna, "LayerCollection", "ListBase", "engine_settings") &&
+		    !DNA_struct_elem_find(fd->filesdna, "LayerCollection", "IDProperty", "properties"))
+		{
+			for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+				for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
+					do_version_layer_collections_idproperties(&sl->layer_collections);
+				}
+			}
+		}
 	}
 }




More information about the Bf-blender-cvs mailing list