[Bf-blender-cvs] [b0998df6084] blender2.8: Layers: Fix scene copying after IDProperty changes

Dalai Felinto noreply at git.blender.org
Fri Mar 31 17:55:01 CEST 2017


Commit: b0998df60842f59d194163042a13cf4e0fde29d8
Author: Dalai Felinto
Date:   Fri Mar 31 17:26:33 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBb0998df60842f59d194163042a13cf4e0fde29d8

Layers: Fix scene copying after IDProperty changes

(also unittest: split scene copy in 4 tests)

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

M	source/blender/blenkernel/intern/scene.c
M	tests/python/render_layer/CMakeLists.txt
M	tests/python/render_layer/render_layer_common.py
D	tests/python/render_layer/test_scene_copy.py
A	tests/python/render_layer/test_scene_copy_a.py
A	tests/python/render_layer/test_scene_copy_b.py
A	tests/python/render_layer/test_scene_copy_c.py
A	tests/python/render_layer/test_scene_copy_d.py

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 38ddd9ebda7..f8a91f63727 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -330,6 +330,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 			}
 			new_sl = new_sl->next;
 		}
+
+		IDPropertyTemplate val = {0};
+		scen->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
 	}
 
 	/* copy color management settings */
@@ -443,6 +446,12 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 
 	BKE_previewimg_id_copy(&scen->id, &sce->id);
 
+	if (type != SCE_COPY_NEW) {
+		if (sce->collection_properties) {
+			IDP_MergeGroup(scen->collection_properties, sce->collection_properties, true);
+		}
+	}
+
 	return scen;
 }
 
diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt
index f03a04a7029..d97672bd2c8 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -138,5 +138,8 @@ RENDER_LAYER_TEST(move_into_layer_collection_i)
 RENDER_LAYER_TEST(move_into_layer_collection_j)
 RENDER_LAYER_TEST(layer_linking)
 RENDER_LAYER_TEST(layer_syncinc)
-RENDER_LAYER_TEST(scene_copy)
+RENDER_LAYER_TEST(scene_copy_a)
+RENDER_LAYER_TEST(scene_copy_b)
+RENDER_LAYER_TEST(scene_copy_c)
+RENDER_LAYER_TEST(scene_copy_d)
 RENDER_LAYER_TEST(scene_write_read)
diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py
index faaefd6b8ed..5d4389482bb 100644
--- a/tests/python/render_layer/render_layer_common.py
+++ b/tests/python/render_layer/render_layer_common.py
@@ -346,6 +346,42 @@ class RenderLayerTesting(unittest.TestCase):
         self.assertEqual(master_collection, bpy.context.scene.master_collection)
         master_collection.objects.link(bpy.data.objects.new('object', None))
 
+    def do_scene_copy(self, filepath_json_reference, copy_mode, data_callbacks):
+        import bpy
+        import os
+        import tempfile
+        import filecmp
+
+        ROOT = self.get_root()
+        with tempfile.TemporaryDirectory() as dirpath:
+            filepath_layers = os.path.join(ROOT, 'layers.blend')
+
+            (self.path_exists(f) for f in (
+                filepath_layers,
+                filepath_json_reference,
+                ))
+
+            filepath_saved = os.path.join(dirpath, '{0}.blend'.format(copy_mode))
+            filepath_json = os.path.join(dirpath, "{0}.json".format(copy_mode))
+
+            bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
+            bpy.ops.scene.new(type=copy_mode)
+            bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_saved)
+
+            datas = query_scene(filepath_saved, 'Main.001', data_callbacks)
+            self.assertTrue(datas, "Data is not valid")
+
+            with open(filepath_json, "w") as f:
+                for data in datas:
+                    f.write(dump(data))
+
+            self.assertTrue(compare_files(
+                filepath_json,
+                filepath_json_reference,
+                ),
+                "Scene copy \"{0}\" test failed".format(copy_mode.title()))
+
     def cleanup_tree(self):
         """
         Remove any existent layer and collections,
diff --git a/tests/python/render_layer/test_scene_copy.py b/tests/python/render_layer/test_scene_copy.py
deleted file mode 100644
index 0b7665f6b28..00000000000
--- a/tests/python/render_layer/test_scene_copy.py
+++ /dev/null
@@ -1,119 +0,0 @@
-# ############################################################
-# Importing - Same For All Render Layer Tests
-# ############################################################
-
-import unittest
-import os
-import sys
-
-sys.path.append(os.path.dirname(__file__))
-from render_layer_common import *
-
-
-# ############################################################
-# Testing
-# ############################################################
-
-class UnitTesting(RenderLayerTesting):
-    def do_scene_copy(self, filepath_json_reference, copy_mode, data_callbacks):
-        import bpy
-        import os
-        import tempfile
-        import filecmp
-
-        ROOT = self.get_root()
-        with tempfile.TemporaryDirectory() as dirpath:
-            filepath_layers = os.path.join(ROOT, 'layers.blend')
-
-            (self.path_exists(f) for f in (
-                filepath_layers,
-                filepath_json_reference,
-                ))
-
-            filepath_saved = os.path.join(dirpath, '{0}.blend'.format(copy_mode))
-            filepath_json = os.path.join(dirpath, "{0}.json".format(copy_mode))
-
-            bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
-            self.rename_collections()
-            bpy.ops.scene.new(type=copy_mode)
-            bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_saved)
-
-            datas = query_scene(filepath_saved, 'Main.001', data_callbacks)
-            self.assertTrue(datas, "Data is not valid")
-
-            with open(filepath_json, "w") as f:
-                for data in datas:
-                    f.write(dump(data))
-
-            self.assertTrue(compare_files(
-                filepath_json,
-                filepath_json_reference,
-                ),
-                "Scene copy \"{0}\" test failed".format(copy_mode.title()))
-
-    def test_scene_collections_copy_full(self):
-        """
-        See if scene copying 'FULL_COPY' is working for scene collections
-        """
-        import os
-        ROOT = self.get_root()
-
-        filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full_simple.json')
-        self.do_scene_copy(
-                filepath_layers_json_copy,
-                'FULL_COPY',
-                (get_scene_collections,))
-
-    def test_scene_collections_link(self):
-        """
-        See if scene copying 'LINK_OBJECTS' is working for scene collections
-        """
-        import os
-        ROOT = self.get_root()
-
-        # note: nothing should change, so using `layers_simple.json`
-        filepath_layers_json_copy = os.path.join(ROOT, 'layers_simple.json')
-        self.do_scene_copy(
-                filepath_layers_json_copy,
-                'LINK_OBJECTS',
-                (get_scene_collections,))
-
-    def test_scene_layers_copy(self):
-        """
-        See if scene copying 'FULL_COPY' is working for scene layers
-        """
-        import os
-        ROOT = self.get_root()
-
-        filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full.json')
-        self.do_scene_copy(
-                filepath_layers_json_copy,
-                'FULL_COPY',
-                (get_scene_collections, get_layers))
-
-    def test_scene_layers_link(self):
-        """
-        See if scene copying 'FULL_COPY' is working for scene layers
-        """
-        import os
-        ROOT = self.get_root()
-
-        filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_link.json')
-        self.do_scene_copy(
-                filepath_layers_json_copy,
-                'LINK_OBJECTS',
-                (get_scene_collections, get_layers))
-
-
-# ############################################################
-# Main - Same For All Render Layer Tests
-# ############################################################
-
-if __name__ == '__main__':
-    import sys
-
-    extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
-    sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
-
-    UnitTesting._extra_arguments = extra_arguments
-    unittest.main()
diff --git a/tests/python/render_layer/test_scene_copy_a.py b/tests/python/render_layer/test_scene_copy_a.py
new file mode 100644
index 00000000000..b8973e9c4b3
--- /dev/null
+++ b/tests/python/render_layer/test_scene_copy_a.py
@@ -0,0 +1,43 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+sys.path.append(os.path.dirname(__file__))
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+    def test_scene_collections_copy_full(self):
+        """
+        See if scene copying 'FULL_COPY' is working for scene collections
+        """
+        import os
+        ROOT = self.get_root()
+
+        filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full_simple.json')
+        self.do_scene_copy(
+                filepath_layers_json_copy,
+                'FULL_COPY',
+                (get_scene_collections,))
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+    import sys
+
+    extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+    sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+    UnitTesting._extra_arguments = extra_arguments
+    unittest.main()
diff --git a/tests/python/render_layer/test_scene_copy_b.py b/tests/python/render_layer/test_scene_copy_b.py
new file mode 100644
index 00000000000..1d6aae7679b
--- /dev/null
+++ b/tests/python/render_layer/test_scene_copy_b.py
@@ -0,0 +1,44 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+sys.path.append(os.path.dirname(__file__))
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+    def test_scene_collections_link(self):
+        """
+        See if scene copying 'LINK_OBJECTS' is working for scene collections


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list