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-05-16 16:37:07 +0300
committerBastien Montagne <bastien@blender.org>2022-05-16 16:37:07 +0300
commit9df91654dc979e3d334de69eded7f816bef223e3 (patch)
treea3d624adec35c0097d54cd3280a1d683fcec8f08
parent48754bc1460428c7a5ffbfc135fe6b5bbe742ec2 (diff)
Fix T98136: Crash undoing "Make Library Override" in some cases.
The 'OVERRIDE_HIDDEN' extra collection would often be mistakenly added to a linked collection, which is totally forbidden and guaranteed to crash on undo/redo. Reworked the code instantiating that extra collection in a more generic and hopefully robust way now.
-rw-r--r--source/blender/blenkernel/intern/lib_override.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 9dc64365f0c..67df6b5527e 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1105,8 +1105,8 @@ static void lib_override_library_create_post_process(Main *bmain,
if (ID_REAL_USERS(ob_new) != 0) {
continue;
}
- default_instantiating_collection = BKE_collection_add(
- bmain, (Collection *)id_root, "OVERRIDE_HIDDEN");
+ default_instantiating_collection = BKE_id_new(bmain, ID_GR, "OVERRIDE_HIDDEN");
+ id_us_min(&default_instantiating_collection->id);
/* Hide the collection from viewport and render. */
default_instantiating_collection->flag |= COLLECTION_HIDE_VIEWPORT |
COLLECTION_HIDE_RENDER;
@@ -1140,6 +1140,20 @@ static void lib_override_library_create_post_process(Main *bmain,
}
}
+ if (id_root != NULL && !ELEM(default_instantiating_collection, NULL, scene->master_collection)) {
+ ID *id_ref = id_root->newid != NULL ? id_root->newid : id_root;
+ switch (GS(id_ref->name)) {
+ case ID_GR:
+ BKE_collection_add_from_collection(
+ bmain, scene, (Collection *)id_ref, default_instantiating_collection);
+ break;
+ default:
+ /* Add to master collection. */
+ BKE_collection_add_from_collection(bmain, scene, NULL, default_instantiating_collection);
+ break;
+ }
+ }
+
BLI_gset_free(all_objects_in_scene, NULL);
}