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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-31 17:14:20 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-09-03 17:29:59 +0300
commitb812dfd1611e045a1446c70b81f830ae67fa3eab (patch)
tree3e092c70be295acfadc1516484a3725d54c98481 /source/blender/blenkernel/intern/collection.c
parent27c954386b279c480410b12e30ca5bd8e57629e7 (diff)
Fix T56622: crash and other bugs deleting scenes.
Simplify library remapping code to handle special collection/object links in postprocess. Previously base contained the actual object link which needed special handling in preprocess, now objects are linked through collection and the base cache can be updated in postprocess.
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 1537743fff4..1f6ab06fb49 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -611,30 +611,37 @@ bool BKE_scene_collections_object_remove(Main *bmain, Scene *scene, Object *ob,
}
/*
- * Remove all NULL objects from non-scene collections.
+ * Remove all NULL objects from collections.
* This is used for library remapping, where these pointers have been set to NULL.
* Otherwise this should never happen.
*/
-void BKE_collections_object_remove_nulls(Main *bmain)
+static void collection_object_remove_nulls(Collection *collection)
{
- for (Collection *collection = bmain->collection.first; collection; collection = collection->id.next) {
- if (!BKE_collection_is_in_scene(collection)) {
- bool changed = false;
-
- for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
- cob_next = cob->next;
+ bool changed = false;
- if (cob->ob == NULL) {
- BLI_freelinkN(&collection->gobject, cob);
- changed = true;
- }
- }
+ for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
+ cob_next = cob->next;
- if (changed) {
- BKE_collection_object_cache_free(collection);
- }
+ if (cob->ob == NULL) {
+ BLI_freelinkN(&collection->gobject, cob);
+ changed = true;
}
}
+
+ if (changed) {
+ BKE_collection_object_cache_free(collection);
+ }
+}
+
+void BKE_collections_object_remove_nulls(Main *bmain)
+{
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ collection_object_remove_nulls(scene->master_collection);
+ }
+
+ for (Collection *collection = bmain->collection.first; collection; collection = collection->id.next) {
+ collection_object_remove_nulls(collection);
+ }
}
/*
@@ -646,15 +653,9 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *old_collection)
{
bool changed = false;
- for (CollectionChild *child = old_collection->children.first; child; child = child->next) {
- CollectionParent *cparent = collection_find_parent(child->collection, old_collection);
- if (cparent) {
- BLI_freelinkN(&child->collection->parents, cparent);
- }
- }
-
- for (CollectionParent *cparent = old_collection->parents.first; cparent; cparent = cparent->next) {
+ for (CollectionParent *cparent = old_collection->parents.first, *cnext; cparent; cparent = cnext) {
Collection *parent = cparent->collection;
+ cnext = cparent->next;
for (CollectionChild *child = parent->children.first, *child_next = NULL; child; child = child_next) {
child_next = child->next;
@@ -664,9 +665,12 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *old_collection)
changed = true;
}
}
- }
- BLI_freelistN(&old_collection->parents);
+ if (!collection_find_child(parent, old_collection)) {
+ BLI_freelinkN(&old_collection->parents, cparent);
+ changed = true;
+ }
+ }
if (changed) {
BKE_main_collection_sync(bmain);