Fix (unreported) crash when deleting collection in freshly duplicated scene.

From startup .blend, add a 'full copy' new scene, and delete its
Collection 1.001 collection. That would make blender crash, once again
due to NULL collection pointer in some ChildrenCollection struct...
This commit is contained in:
Bastien Montagne 2018-11-10 16:22:41 +01:00
parent 78ebb59604
commit fcf6f78d19
1 changed files with 6 additions and 2 deletions

View File

@ -323,10 +323,14 @@ static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *o
/* Can be called with both old_collection and new_collection being NULL,
* this means we have to check whole Main database then. */
static void libblock_remap_data_postprocess_collection_update(
Main *bmain, Collection *old_collection, Collection *new_collection)
Main *bmain, Collection *UNUSED(old_collection), Collection *new_collection)
{
if (new_collection == NULL) {
BKE_collections_child_remove_nulls(bmain, old_collection);
/* XXX Complex cases can lead to NULL pointers in other collections than old_collection,
* and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check whole
* existing collections for NULL pointers.
* I'd consider optimizing that whole collection remapping process a TODO for later. */
BKE_collections_child_remove_nulls(bmain, NULL /*old_collection*/);
}
BKE_main_collection_sync_remap(bmain);