Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-02-23 14:35:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-02-24 12:10:24 +0300
commit2f9a0dfe6429661f1d4bdf28398504df7fe98beb (patch)
treeb95bf074a6b3f6246b99ebda3a663ed435dda150 /release/scripts/modules/bpy_extras/object_utils.py
parent8261a84ffbe6d6a88389f374656135cef53e5b15 (diff)
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)
Diffstat (limited to 'release/scripts/modules/bpy_extras/object_utils.py')
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index d740137b0c3..83d3b2066b4 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -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')