Util function to free CollectionEngineSettings
authorDalai Felinto <dfelinto@gmail.com>
Fri, 3 Feb 2017 10:56:59 +0000 (11:56 +0100)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 3 Feb 2017 11:23:01 +0000 (12:23 +0100)
This may be run by Depsgraph, as well as internal layercollection free routines

source/blender/blenkernel/BKE_layer.h
source/blender/blenkernel/intern/layer.c

index 3fb898fa82c78ae6dfea94745afde99a61aa2a30..3253c1e5e292fe129a3c072a3ecde44bea91c2cd 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
 struct CollectionEngineSettings;
 struct LayerCollection;
 struct ID;
+struct ListBase;
 struct Main;
 struct Object;
 struct ObjectBase;
@@ -98,6 +99,7 @@ typedef void (*CollectionEngineSettingsCB)(struct RenderEngine *engine, struct C
 struct CollectionEngineSettings *BKE_layer_collection_engine_get(struct LayerCollection *lc, const char *engine_name);
 void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, CollectionEngineSettingsCB func);
 void BKE_layer_collection_engine_settings_callback_free(void);
+void BKE_layer_collection_engine_settings_free(struct ListBase *lb);
 
 void BKE_collection_engine_property_add_float(struct CollectionEngineSettings *ces, const char *name, float value);
 void BKE_collection_engine_property_add_int(struct CollectionEngineSettings *ces, const char *name, int value);
index 6b77b556a1b6e9dc201e83be1843a953dd323a9f..d64a2ba585e1c18ff23e86bafd85b46969ae4d98 100644 (file)
@@ -293,16 +293,12 @@ static void layer_collection_free(SceneLayer *sl, LayerCollection *lc)
 
        BLI_freelistN(&lc->object_bases);
        BLI_freelistN(&lc->overrides);
+       BKE_layer_collection_engine_settings_free(&lc->engine_settings);
 
        for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
                layer_collection_free(sl, nlc);
        }
 
-       for (CollectionEngineSettings *cse = lc->engine_settings.first; cse; cse = cse->next) {
-               BLI_freelistN(&cse->properties);
-       }
-       BLI_freelistN(&lc->engine_settings);
-
        BLI_freelistN(&lc->layer_collections);
 }
 
@@ -660,6 +656,20 @@ void BKE_layer_collection_engine_settings_callback_free(void)
        BLI_freelistN(&R_engines_settings_callbacks);
 }
 
+/**
+ * Free the CollectionEngineSettings ListBase
+ *
+ * Usually we would pass LayerCollection->engine_settings
+ * But depsgraph uses this for Object->collection_settings
+ */
+void BKE_layer_collection_engine_settings_free(ListBase *lb)
+{
+       for (CollectionEngineSettings *cse = lb->first; cse; cse = cse->next) {
+               BLI_freelistN(&cse->properties);
+       }
+       BLI_freelistN(lb);
+}
+
 /**
  * Initialize the render settings for a single LayerCollection
  */