Cleanup: ID make local: remove id_in_bmain argument.

This info is now stored in ID tags themselves, so no need to pass an
extra anonymous boolean parameter around, yay!
This commit is contained in:
2020-03-04 11:05:41 +01:00
parent 76d8e8693f
commit 4e597a5cff
30 changed files with 40 additions and 50 deletions

View File

@@ -190,10 +190,7 @@ void id_fake_user_set(struct ID *id);
void id_fake_user_clear(struct ID *id);
void BKE_id_clear_newpoin(struct ID *id);
void BKE_lib_id_make_local_generic(struct Main *bmain,
struct ID *id,
const bool id_in_mainlist,
const bool lib_local);
void BKE_lib_id_make_local_generic(struct Main *bmain, struct ID *id, const bool lib_local);
bool BKE_lib_id_make_local(struct Main *bmain,
struct ID *id,
const bool test,

View File

@@ -399,10 +399,7 @@ struct bNodeTree **BKE_ntree_ptr_from_id(struct ID *id);
struct bNodeTree *ntreeFromID(struct ID *id);
struct ID *BKE_node_tree_find_owner_ID(struct Main *bmain, struct bNodeTree *ntree);
void ntreeMakeLocal(struct Main *bmain,
struct bNodeTree *ntree,
bool id_in_mainlist,
const bool lib_local);
void ntreeMakeLocal(struct Main *bmain, struct bNodeTree *ntree, const bool lib_local);
void ntreeFreeLocalNode(struct bNodeTree *ntree, struct bNode *node);
void ntreeFreeLocalTree(struct bNodeTree *ntree);
struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);

View File

@@ -93,7 +93,7 @@ bAction *BKE_action_add(Main *bmain, const char name[])
// does copy_fcurve...
void BKE_action_make_local(Main *bmain, bAction *act, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &act->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &act->id, lib_local);
}
/* .................................. */

View File

@@ -138,7 +138,7 @@ void BKE_armature_free(bArmature *arm)
void BKE_armature_make_local(Main *bmain, bArmature *arm, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &arm->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &arm->id, lib_local);
}
static void copy_bonechildren(Bone *bone_dst,

View File

@@ -213,7 +213,7 @@ CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &cache_file->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &cache_file->id, lib_local);
}
void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)

View File

@@ -98,7 +98,7 @@ Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
void BKE_camera_make_local(Main *bmain, Camera *cam, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &cam->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &cam->id, lib_local);
}
/** Free (or release) any data used by this camera (does not free the camera itself). */

View File

@@ -371,7 +371,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
void BKE_collection_make_local(Main *bmain, Collection *collection, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &collection->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &collection->id, lib_local);
}
/********************************* Naming *******************************/

View File

@@ -222,7 +222,7 @@ Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
void BKE_curve_make_local(Main *bmain, Curve *cu, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &cu->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &cu->id, lib_local);
}
/* Get list of nurbs from editnurbs structure */

View File

@@ -327,7 +327,7 @@ VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath)
void BKE_vfont_make_local(Main *bmain, VFont *vfont, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &vfont->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &vfont->id, lib_local);
}
static VFont *which_vfont(Curve *cu, CharInfo *info)

View File

@@ -709,7 +709,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &gpd->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &gpd->id, lib_local);
}
/* ************************************************** */

View File

@@ -464,7 +464,7 @@ Image *BKE_image_copy(Main *bmain, const Image *ima)
void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &ima->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &ima->id, lib_local);
}
void BKE_image_merge(Main *bmain, Image *dest, Image *source)

View File

@@ -331,7 +331,7 @@ void BKE_lattice_free(Lattice *lt)
void BKE_lattice_make_local(Main *bmain, Lattice *lt, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &lt->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &lt->id, lib_local);
}
typedef struct LatticeDeformData {

View File

@@ -157,10 +157,11 @@ static void lib_id_library_local_paths(Main *bmain, Library *lib, ID *id)
* Pull an ID out of a library (make it local). Only call this for IDs that
* don't have other library users.
*/
static void lib_id_clear_library_data_ex(Main *bmain, ID *id, const bool id_in_mainlist)
static void lib_id_clear_library_data_ex(Main *bmain, ID *id)
{
bNodeTree *ntree = NULL;
Key *key = NULL;
const bool id_in_mainlist = (id->tag & LIB_TAG_NO_MAIN) == 0;
lib_id_library_local_paths(bmain, id->lib, id);
@@ -178,20 +179,18 @@ static void lib_id_clear_library_data_ex(Main *bmain, ID *id, const bool id_in_m
/* Internal bNodeTree blocks inside data-blocks also stores id->lib,
* make sure this stays in sync. */
if ((ntree = ntreeFromID(id))) {
lib_id_clear_library_data_ex(
bmain, &ntree->id, false); /* Datablocks' nodetree is never in Main. */
lib_id_clear_library_data_ex(bmain, &ntree->id);
}
/* Same goes for shapekeys. */
if ((key = BKE_key_from_id(id))) {
lib_id_clear_library_data_ex(
bmain, &key->id, id_in_mainlist); /* sigh, why are keys in Main? */
lib_id_clear_library_data_ex(bmain, &key->id);
}
}
void BKE_lib_id_clear_library_data(Main *bmain, ID *id)
{
lib_id_clear_library_data_ex(bmain, id, true);
lib_id_clear_library_data_ex(bmain, id);
}
void id_lib_extern(ID *id)
@@ -378,10 +377,7 @@ static void lib_id_copy_ensure_local(Main *bmain, const ID *old_id, ID *new_id)
/**
* Generic 'make local' function, works for most of data-block types...
*/
void BKE_lib_id_make_local_generic(Main *bmain,
ID *id,
const bool id_in_mainlist,
const bool lib_local)
void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const bool lib_local)
{
bool is_local = false, is_lib = false;
@@ -400,7 +396,7 @@ void BKE_lib_id_make_local_generic(Main *bmain,
if (lib_local || is_local) {
if (!is_lib) {
lib_id_clear_library_data_ex(bmain, id, id_in_mainlist);
lib_id_clear_library_data_ex(bmain, id);
BKE_lib_id_expand_local(bmain, id);
}
else {
@@ -551,7 +547,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const bool lib_
return true;
case ID_NT:
if (!test) {
ntreeMakeLocal(bmain, (bNodeTree *)id, true, lib_local);
ntreeMakeLocal(bmain, (bNodeTree *)id, lib_local);
}
return true;
case ID_BR:
@@ -2226,7 +2222,7 @@ void BKE_library_make_local(Main *bmain,
* currently there are some indirect usages. So instead of making a copy that we'll likely
* get rid of later, directly make that data block local.
* Saves a tremendous amount of time with complex scenes... */
lib_id_clear_library_data_ex(bmain, id, true);
lib_id_clear_library_data_ex(bmain, id);
BKE_lib_id_expand_local(bmain, id);
id->tag &= ~LIB_TAG_DOIT;

View File

@@ -131,7 +131,7 @@ Light *BKE_light_localize(Light *la)
void BKE_light_make_local(Main *bmain, Light *la, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &la->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &la->id, lib_local);
}
void BKE_light_free(Light *la)

View File

@@ -103,7 +103,7 @@ LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
void BKE_lightprobe_make_local(Main *bmain, LightProbe *probe, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &probe->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &probe->id, lib_local);
}
void BKE_lightprobe_free(LightProbe *probe)

View File

@@ -190,7 +190,7 @@ void BKE_linestyle_make_local(struct Main *bmain,
FreestyleLineStyle *linestyle,
const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &linestyle->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &linestyle->id, lib_local);
}
FreestyleLineStyle *BKE_linestyle_active_from_view_layer(ViewLayer *view_layer)

View File

@@ -908,7 +908,7 @@ Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
void BKE_mask_make_local(Main *bmain, Mask *mask, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &mask->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &mask->id, lib_local);
}
void BKE_mask_point_free(MaskSplinePoint *point)

View File

@@ -232,7 +232,7 @@ Material *BKE_material_localize(Material *ma)
void BKE_material_make_local(Main *bmain, Material *ma, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &ma->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &ma->id, lib_local);
}
Material ***BKE_object_material_array(Object *ob)

View File

@@ -127,7 +127,7 @@ MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
void BKE_mball_make_local(Main *bmain, MetaBall *mb, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &mb->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &mb->id, lib_local);
}
/* most simple meta-element adding function

View File

@@ -838,7 +838,7 @@ Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(BMEditMesh *em,
void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &me->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &me->id, lib_local);
}
BoundBox *BKE_mesh_boundbox_get(Object *ob)

View File

@@ -1668,7 +1668,7 @@ MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
void BKE_movieclip_make_local(Main *bmain, MovieClip *clip, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &clip->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &clip->id, lib_local);
}
float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr)

View File

@@ -2296,9 +2296,9 @@ ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
return NULL;
}
void ntreeMakeLocal(Main *bmain, bNodeTree *ntree, bool id_in_mainlist, const bool lib_local)
void ntreeMakeLocal(Main *bmain, bNodeTree *ntree, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &ntree->id, id_in_mainlist, lib_local);
BKE_lib_id_make_local_generic(bmain, &ntree->id, lib_local);
}
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)

View File

@@ -519,7 +519,7 @@ PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &pc->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &pc->id, lib_local);
}
Palette *BKE_paint_palette(Paint *p)
@@ -606,7 +606,7 @@ Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
void BKE_palette_make_local(Main *bmain, Palette *palette, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &palette->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &palette->id, lib_local);
}
void BKE_palette_init(Palette *palette)

View File

@@ -3839,7 +3839,7 @@ ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings
void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &part->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &part->id, lib_local);
}
/************************************************/

View File

@@ -492,7 +492,7 @@ void BKE_scene_make_local(Main *bmain, Scene *sce, const bool lib_local)
{
/* For now should work, may need more work though to support all possible corner cases
* (also scene_copy probably needs some love). */
BKE_lib_id_make_local_generic(bmain, &sce->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &sce->id, lib_local);
}
/** Free (or release) any data used by this scene (does not free the scene itself). */

View File

@@ -219,7 +219,7 @@ void BKE_sound_copy_data(Main *UNUSED(bmain),
void BKE_sound_make_local(Main *bmain, bSound *sound, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &sound->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &sound->id, lib_local);
}
#ifdef WITH_AUDASPACE

View File

@@ -76,7 +76,7 @@ Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
void BKE_speaker_make_local(Main *bmain, Speaker *spk, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &spk->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &spk->id, lib_local);
}
void BKE_speaker_free(Speaker *spk)

View File

@@ -443,7 +443,7 @@ Text *BKE_text_copy(Main *bmain, const Text *ta)
void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &text->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &text->id, lib_local);
}
void BKE_text_clear(Text *text) /* called directly from rna */

View File

@@ -388,7 +388,7 @@ Tex *BKE_texture_localize(Tex *tex)
void BKE_texture_make_local(Main *bmain, Tex *tex, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &tex->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &tex->id, lib_local);
}
Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)

View File

@@ -156,7 +156,7 @@ World *BKE_world_localize(World *wrld)
void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
{
BKE_lib_id_make_local_generic(bmain, &wrld->id, true, lib_local);
BKE_lib_id_make_local_generic(bmain, &wrld->id, lib_local);
}
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)