diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_collection.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 9 |
4 files changed, 22 insertions, 14 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 35d8f336207..0adac4500f8 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -46,7 +46,7 @@ struct SceneCollection *BKE_collection_add(struct Scene *scene, struct SceneColl bool BKE_collection_remove(struct Scene *scene, struct SceneCollection *sc); struct SceneCollection *BKE_collection_master(const struct Scene *scene); void BKE_collection_rename(const struct Scene *scene, struct SceneCollection *sc, const char *name); -void BKE_collection_master_free(struct Scene *scene); +void BKE_collection_master_free(struct Scene *scene, const bool do_id_user); void BKE_collection_object_add(const struct Scene *scene, struct SceneCollection *sc, struct Object *object); void BKE_collection_object_add_from(struct Scene *scene, struct Object *ob_src, struct Object *ob_dst); void BKE_collection_object_remove(struct Main *bmain, const struct Scene *scene, struct SceneCollection *sc, struct Object *object, const bool free_us); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index cd59ef98903..5047070012c 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -71,6 +71,7 @@ struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base); void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); +void BKE_scene_free_ex(struct Scene *sce, const bool do_id_user); void BKE_scene_free(struct Scene *sce); void BKE_scene_init(struct Scene *sce); struct Scene *BKE_scene_add(struct Main *bmain, const char *name); diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 507ae1a4e70..3bf3a5ce5a4 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -75,20 +75,22 @@ SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, co /** * Free the collection items recursively */ -static void collection_free(SceneCollection *sc) +static void collection_free(SceneCollection *sc, const bool do_id_user) { - for (LinkData *link = sc->objects.first; link; link = link->next) { - id_us_min(link->data); + if (do_id_user) { + for (LinkData *link = sc->objects.first; link; link = link->next) { + id_us_min(link->data); + } + for (LinkData *link = sc->filter_objects.first; link; link = link->next) { + id_us_min(link->data); + } } - BLI_freelistN(&sc->objects); - for (LinkData *link = sc->filter_objects.first; link; link = link->next) { - id_us_min(link->data); - } + BLI_freelistN(&sc->objects); BLI_freelistN(&sc->filter_objects); for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { - collection_free(nsc); + collection_free(nsc, do_id_user); } BLI_freelistN(&sc->scene_collections); } @@ -160,7 +162,7 @@ bool BKE_collection_remove(Scene *scene, SceneCollection *sc) } /* clear the collection items */ - collection_free(sc); + collection_free(sc, true); /* check all layers that use this collection and clear them */ for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) { @@ -218,9 +220,9 @@ void BKE_collection_rename(const Scene *scene, SceneCollection *sc, const char * * Free (or release) any data used by the master collection (does not free the master collection itself). * Used only to clear the entire scene data since it's not doing re-syncing of the LayerCollection tree */ -void BKE_collection_master_free(Scene *scene) +void BKE_collection_master_free(Scene *scene, const bool do_id_user) { - collection_free(BKE_collection_master(scene)); + collection_free(BKE_collection_master(scene), do_id_user); } static void collection_object_add(const Scene *scene, SceneCollection *sc, Object *ob) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d2e6450f0de..94372588957 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -482,7 +482,7 @@ void BKE_scene_make_local(Main *bmain, Scene *sce, const bool lib_local) } /** Free (or release) any data used by this scene (does not free the scene itself). */ -void BKE_scene_free(Scene *sce) +void BKE_scene_free_ex(Scene *sce, const bool do_id_user) { SceneRenderLayer *srl; @@ -590,7 +590,7 @@ void BKE_scene_free(Scene *sce) } /* Master Collection */ - BKE_collection_master_free(sce); + BKE_collection_master_free(sce, do_id_user); MEM_freeN(sce->collection); sce->collection = NULL; @@ -609,6 +609,11 @@ void BKE_scene_free(Scene *sce) } } +void BKE_scene_free(Scene *sce) +{ + return BKE_scene_free_ex(sce, true); +} + void BKE_scene_init(Scene *sce) { ParticleEditSettings *pset; |