[Bf-blender-cvs] [9df91654dc9] blender-v3.2-release: Fix T98136: Crash undoing "Make Library Override" in some cases.
Bastien Montagne
noreply at git.blender.org
Mon May 16 15:39:25 CEST 2022
Commit: 9df91654dc979e3d334de69eded7f816bef223e3
Author: Bastien Montagne
Date: Mon May 16 15:37:07 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB9df91654dc979e3d334de69eded7f816bef223e3
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.
===================================================================
M source/blender/blenkernel/intern/lib_override.c
===================================================================
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);
}
More information about the Bf-blender-cvs
mailing list