Cleanup: Move `BKE_animdata_free()` call out of each IDType free data.

This has been long standing TODO...

Note that remaining usages of BKE_xxx_delete should all be carefully
checked for and utilmately nuked in favor of `BKE_id_delete()`, think we
still have quiet a few bugs hidden in those (code seems to usually
assume those functions do a full ID deletion, which is not the case).
This commit is contained in:
Bastien Montagne 2020-03-09 18:40:06 +01:00
parent 6472a721f0
commit be2e41c397
23 changed files with 17 additions and 51 deletions

View File

@ -138,7 +138,6 @@ static void armature_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src
static void armature_free_data(struct ID *id)
{
bArmature *armature = (bArmature *)id;
BKE_animdata_free(&armature->id, false);
BKE_armature_bone_hash_free(armature);
BKE_armature_bonelist_free(&armature->bonebase);

View File

@ -80,7 +80,6 @@ static void cache_file_copy_data(Main *UNUSED(bmain),
static void cache_file_free_data(ID *id)
{
CacheFile *cache_file = (CacheFile *)id;
BKE_animdata_free((ID *)cache_file, false);
cachefile_handle_free(cache_file);
BLI_freelistN(&cache_file->object_paths);
}

View File

@ -112,8 +112,6 @@ static void camera_free_data(ID *id)
{
Camera *cam = (Camera *)id;
BLI_freelistN(&cam->bg_images);
BKE_animdata_free(id, false);
}
IDTypeInfo IDType_ID_CA = {

View File

@ -105,8 +105,6 @@ static void curve_free_data(ID *id)
{
Curve *curve = (Curve *)id;
BKE_animdata_free((ID *)curve, false);
BKE_curve_batch_cache_free(curve);
BKE_nurbList_free(&curve->nurb);

View File

@ -263,9 +263,6 @@ void BKE_gpencil_free_layers(ListBase *list)
/** Free (or release) any data used by this grease pencil (does not free the gpencil itself). */
void BKE_gpencil_free(bGPdata *gpd, bool free_all)
{
/* clear animation data */
BKE_animdata_free(&gpd->id, false);
/* free layers */
BKE_gpencil_free_layers(&gpd->layers);

View File

@ -84,8 +84,6 @@ static void shapekey_free_data(ID *id)
Key *key = (Key *)id;
KeyBlock *kb;
BKE_animdata_free((ID *)key, false);
while ((kb = BLI_pophead(&key->block))) {
if (kb->data) {
MEM_freeN(kb->data);

View File

@ -99,8 +99,6 @@ static void lattice_free_data(ID *id)
{
Lattice *lattice = (Lattice *)id;
BKE_animdata_free(&lattice->id, false);
BKE_lattice_batch_cache_free(lattice);
MEM_SAFE_FREE(lattice->def);

View File

@ -57,6 +57,7 @@
#include "BLI_listbase.h"
#include "BKE_action.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_brush.h"
#include "BKE_camera.h"
@ -119,8 +120,7 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
BKE_lib_override_library_free(&id->override_library, do_id_user);
}
/* XXX TODO remove animdata handling from each type's freeing func,
* and do it here, like for copy! */
BKE_animdata_free(id, do_id_user);
}
void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))

View File

@ -143,7 +143,6 @@ static void light_make_local(Main *bmain, ID *id, const int flags)
static void light_free_data(ID *id)
{
Light *la = (Light *)id;
BKE_animdata_free(&la->id, false);
BKE_curvemapping_free(la->curfalloff);

View File

@ -110,11 +110,6 @@ static void lightprobe_make_local(Main *bmain, ID *id, const int flags)
BKE_lib_id_make_local_generic(bmain, id, flags);
}
static void lightprobe_free_data(ID *id)
{
BKE_animdata_free(id, false);
}
IDTypeInfo IDType_ID_LP = {
.id_code = ID_LP,
.id_filter = FILTER_ID_LP,
@ -127,6 +122,6 @@ IDTypeInfo IDType_ID_LP = {
.init_data = lightprobe_init_data,
.copy_data = lightprobe_copy_data,
.free_data = lightprobe_free_data,
.free_data = NULL,
.make_local = lightprobe_make_local,
};

View File

@ -120,8 +120,6 @@ static void linestyle_free_data(ID *id)
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
LineStyleModifier *linestyle_modifier;
BKE_animdata_free(&linestyle->id, false);
for (int material_slot_index = 0; material_slot_index < MAX_MTEX; material_slot_index++) {
MEM_SAFE_FREE(linestyle->mtex[material_slot_index]);
}

View File

@ -81,8 +81,6 @@ static void mask_free_data(ID *id)
{
Mask *mask = (Mask *)id;
BKE_animdata_free((ID *)mask, false);
/* free mask data */
BKE_mask_layer_free_list(&mask->masklayers);
}

View File

@ -123,8 +123,6 @@ static void material_free_data(ID *id)
{
Material *material = (Material *)id;
BKE_animdata_free((ID *)material, false);
/* Free gpu material before the ntree */
GPU_material_free(&material->gpumaterial);

View File

@ -92,8 +92,6 @@ static void metaball_free_data(ID *id)
{
MetaBall *metaball = (MetaBall *)id;
BKE_animdata_free((ID *)metaball, false);
BKE_mball_batch_cache_free(metaball);
MEM_SAFE_FREE(metaball->mat);

View File

@ -61,6 +61,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
static void mesh_clear_geometry(Mesh *mesh);
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata);
static void mesh_init_data(ID *id)
@ -136,7 +137,9 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
static void mesh_free_data(ID *id)
{
Mesh *mesh = (Mesh *)id;
BKE_mesh_clear_geometry(mesh);
BKE_mesh_runtime_clear_cache(mesh);
mesh_clear_geometry(mesh);
MEM_SAFE_FREE(mesh->mat);
}
@ -586,11 +589,8 @@ void BKE_mesh_free(Mesh *me)
mesh_free_data(&me->id);
}
void BKE_mesh_clear_geometry(Mesh *mesh)
static void mesh_clear_geometry(Mesh *mesh)
{
BKE_animdata_free(&mesh->id, false);
BKE_mesh_runtime_clear_cache(mesh);
CustomData_free(&mesh->vdata, mesh->totvert);
CustomData_free(&mesh->edata, mesh->totedge);
CustomData_free(&mesh->fdata, mesh->totface);
@ -615,6 +615,13 @@ void BKE_mesh_clear_geometry(Mesh *mesh)
BKE_mesh_update_customdata_pointers(mesh, false);
}
void BKE_mesh_clear_geometry(Mesh *mesh)
{
BKE_animdata_free(&mesh->id, false);
BKE_mesh_runtime_clear_cache(mesh);
mesh_clear_geometry(mesh);
}
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
{
if (free_customdata) {

View File

@ -105,7 +105,6 @@ static void movie_clip_free_data(ID *id)
free_buffers(movie_clip);
BKE_tracking_free(&movie_clip->tracking);
BKE_animdata_free((ID *)movie_clip, false);
}
IDTypeInfo IDType_ID_MC = {

View File

@ -195,8 +195,6 @@ static void ntree_free_data(ID *id)
bNode *node, *next;
bNodeSocket *sock, *nextsock;
BKE_animdata_free((ID *)ntree, false);
/* XXX hack! node trees should not store execution graphs at all.
* This should be removed when old tree types no longer require it.
* Currently the execution data for texture nodes remains in the tree
@ -2156,6 +2154,7 @@ static void free_localized_node_groups(bNodeTree *ntree)
void ntreeFreeTree(bNodeTree *ntree)
{
ntree_free_data(&ntree->id);
BKE_animdata_free(&ntree->id, false);
}
void ntreeFreeNestedTree(bNodeTree *ntree)

View File

@ -272,7 +272,6 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
static void object_free_data(ID *id)
{
Object *ob = (Object *)id;
BKE_animdata_free((ID *)ob, false);
DRW_drawdata_free((ID *)ob);

View File

@ -123,8 +123,6 @@ static void particle_settings_free_data(ID *id)
{
ParticleSettings *particle_settings = (ParticleSettings *)id;
BKE_animdata_free((ID *)particle_settings, false);
for (int a = 0; a < MAX_MTEX; a++) {
MEM_SAFE_FREE(particle_settings->mtex[a]);
}

View File

@ -333,8 +333,6 @@ static void scene_free_data(ID *id)
Scene *scene = (Scene *)id;
const bool do_id_user = false;
BKE_animdata_free((ID *)scene, false);
BKE_sequencer_editing_free(scene, do_id_user);
BKE_keyingsets_free(&scene->keyingsets);

View File

@ -43,11 +43,6 @@ static void speaker_init_data(ID *id)
MEMCPY_STRUCT_AFTER(speaker, DNA_struct_default_get(Speaker), id);
}
static void speaker_free_data(ID *id)
{
BKE_animdata_free(id, false);
}
IDTypeInfo IDType_ID_SPK = {
.id_code = ID_SPK,
.id_filter = FILTER_ID_SPK,
@ -60,7 +55,7 @@ IDTypeInfo IDType_ID_SPK = {
.init_data = speaker_init_data,
.copy_data = NULL,
.free_data = speaker_free_data,
.free_data = NULL,
.make_local = NULL,
};

View File

@ -109,7 +109,6 @@ static void texture_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const i
static void texture_free_data(ID *id)
{
Tex *texture = (Tex *)id;
BKE_animdata_free((ID *)texture, false);
/* is no lib link block, but texture extension */
if (texture->nodetree) {

View File

@ -55,7 +55,6 @@
static void world_free_data(ID *id)
{
World *wrld = (World *)id;
BKE_animdata_free(id, false);
DRW_drawdata_free(id);