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:
authorBastien Montagne <bastien@blender.org>2022-06-01 13:44:11 +0300
committerBastien Montagne <bastien@blender.org>2022-06-01 16:04:34 +0300
commite72b86d3cba8c7366bee2e92162f3b07bf367f3d (patch)
treee93ed98e072576085dbc58d918551aa93cf86571 /source/blender/editors/object
parent7dd0258d4a439335fd69a4f0d1716a67c926ffe8 (diff)
Fix T98469: Crash trying to add an object to a linked collection that is linked to multiple scenes.
Crash happened because code could not find a valid base in current scene after adding the object, added some checks for that. Root of the issue was wrong assumptions in `BKE_object_add` logic, which would pick the first valid ancestor collection in case initially selected collection was not editable. In some case, this could pick a collection not instanced in the current scene's view layer, leading to not getting a valid base for the newly added object. Addressed this by adding a new variant of `BKE_collection_object_add`, `BKE_collection_viewlayer_object_add`, which ensures final collection is in given viewlayer.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 20b9844ac89..e486d606e91 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -621,9 +621,16 @@ Object *ED_object_add_type_with_obdata(bContext *C,
else {
ob = BKE_object_add(bmain, view_layer, type, name);
}
- BASACT(view_layer)->local_view_bits = local_view_bits;
- /* editor level activate, notifiers */
- ED_object_base_activate(C, view_layer->basact);
+
+ Base *ob_base_act = BASACT(view_layer);
+ /* While not getting a valid base is not a good thing, it can happen in convoluted corner cases,
+ * better not crash on it in releases. */
+ BLI_assert(ob_base_act != nullptr);
+ if (ob_base_act != nullptr) {
+ ob_base_act->local_view_bits = local_view_bits;
+ /* editor level activate, notifiers */
+ ED_object_base_activate(C, ob_base_act);
+ }
/* more editor stuff */
ED_object_base_init_transform_on_add(ob, loc, rot);