Fix T50714: Collections: Adding object to scene without an existing collection

This was causing blender to segfault.

We now add create a new collection and link to the layer before adding
the new object

(also included unittests, and requires updated lib/tests)
This commit is contained in:
Dalai Felinto
2017-02-23 12:35:14 +01:00
parent 8261a84ffb
commit 2f9a0dfe64
7 changed files with 164 additions and 1 deletions

View File

@@ -121,7 +121,14 @@ def object_data_add(context, obdata, operator=None, name=None):
"""
scene = context.scene
layer = context.render_layer
scene_collection = context.scene_collection
layer_collection = context.layer_collection
if not layer_collection:
# when there is no collection linked to this render_layer create one
scene_collection = scene.master_collection.collections.new("")
layer_collection = layer.collections.link(scene_collection)
else:
scene_collection = layer_collection.collection
bpy.ops.object.select_all(action='DESELECT')