Refactor ID make local to use a single flag parameter.

Instead of using anonymous booleans flags, also allows to keep the same
behavior in all cases, without needing special handling from calling
code for our beloved oddballs object proxies...
This commit is contained in:
Bastien Montagne 2020-03-04 11:42:15 +01:00
parent 4e597a5cff
commit 4bfa256ea4
63 changed files with 152 additions and 161 deletions

View File

@ -57,7 +57,7 @@ struct bAction *BKE_action_copy(struct Main *bmain, const struct bAction *act_sr
/* Deallocate all of the Action's data, but not the Action itself */
void BKE_action_free(struct bAction *act);
void BKE_action_make_local(struct Main *bmain, struct bAction *act, const bool lib_local);
void BKE_action_make_local(struct Main *bmain, struct bAction *act, const int flags);
/* Action API ----------------- */

View File

@ -68,7 +68,7 @@ struct bArmature *BKE_armature_from_object(struct Object *ob);
int BKE_armature_bonelist_count(struct ListBase *lb);
void BKE_armature_bonelist_free(struct ListBase *lb);
void BKE_armature_free(struct bArmature *arm);
void BKE_armature_make_local(struct Main *bmain, struct bArmature *arm, const bool lib_local);
void BKE_armature_make_local(struct Main *bmain, struct bArmature *arm, const int flags);
void BKE_armature_copy_data(struct Main *bmain,
struct bArmature *arm_dst,
const struct bArmature *arm_src,

View File

@ -55,7 +55,7 @@ void BKE_brush_copy_data(struct Main *bmain,
const struct Brush *brush_src,
const int flag);
struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
void BKE_brush_make_local(struct Main *bmain, struct Brush *brush, const bool lib_local);
void BKE_brush_make_local(struct Main *bmain, struct Brush *brush, const int flags);
void BKE_brush_free(struct Brush *brush);
void BKE_brush_sculpt_reset(struct Brush *brush);

View File

@ -51,7 +51,7 @@ struct CacheFile *BKE_cachefile_copy(struct Main *bmain, const struct CacheFile
void BKE_cachefile_make_local(struct Main *bmain,
struct CacheFile *cache_file,
const bool lib_local);
const int flags);
void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file);

View File

@ -47,7 +47,7 @@ void BKE_camera_copy_data(struct Main *bmain,
const struct Camera *cam_src,
const int flag);
struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const bool lib_local);
void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const int flags);
void BKE_camera_free(struct Camera *ca);
/* Camera Usage */

View File

@ -62,7 +62,7 @@ void BKE_collection_copy_data(struct Main *bmain,
const int flag);
void BKE_collection_make_local(struct Main *bmain,
struct Collection *collection,
const bool lib_local);
const int flags);
struct Collection *BKE_collection_duplicate(struct Main *bmain,
struct Collection *parent,

View File

@ -85,7 +85,7 @@ void BKE_curve_copy_data(struct Main *bmain,
const struct Curve *cu_src,
const int flag);
struct Curve *BKE_curve_copy(struct Main *bmain, const struct Curve *cu);
void BKE_curve_make_local(struct Main *bmain, struct Curve *cu, const bool lib_local);
void BKE_curve_make_local(struct Main *bmain, struct Curve *cu, const int flags);
short BKE_curve_type_get(struct Curve *cu);
void BKE_curve_type_test(struct Object *ob);
void BKE_curve_curve_dimension_update(struct Curve *cu);

View File

@ -82,7 +82,7 @@ struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
struct VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists);
struct VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath);
void BKE_vfont_make_local(struct Main *bmain, struct VFont *vfont, const bool lib_local);
void BKE_vfont_make_local(struct Main *bmain, struct VFont *vfont, const int flags);
bool BKE_vfont_to_curve_ex(struct Object *ob,
struct Curve *cu,

View File

@ -99,7 +99,7 @@ struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
const struct bGPdata *gpd,
bool internal_copy);
void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const bool lib_local);
void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const int flags);
void BKE_gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);

View File

@ -142,7 +142,7 @@ struct anim *openanim_noload(const char *name,
int streamindex,
char colorspace[IMA_MAX_SPACE]);
void BKE_image_make_local(struct Main *bmain, struct Image *ima, const bool lib_local);
void BKE_image_make_local(struct Main *bmain, struct Image *ima, const int flags);
void BKE_image_tag_time(struct Image *ima);

View File

@ -49,7 +49,7 @@ void BKE_lattice_copy_data(struct Main *bmain,
const int flag);
struct Lattice *BKE_lattice_copy(struct Main *bmain, const struct Lattice *lt);
void BKE_lattice_free(struct Lattice *lt);
void BKE_lattice_make_local(struct Main *bmain, struct Lattice *lt, const bool lib_local);
void BKE_lattice_make_local(struct Main *bmain, struct Lattice *lt, const int flags);
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
struct LatticeDeformData *init_latt_deform(struct Object *oblatt,

View File

@ -190,11 +190,18 @@ 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 lib_local);
bool BKE_lib_id_make_local(struct Main *bmain,
struct ID *id,
const bool test,
const bool force_local);
/** Flags to control make local code behaviour. */
enum {
/** Making that ID local is part of making local a whole library. */
LIB_ID_MAKELOCAL_FULL_LIBRARY = 1 << 0,
/* Special type-specific options. */
/** For Objects, do not clear the proxy pointers while making the data-block local. */
LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING = 1 << 16,
};
void BKE_lib_id_make_local_generic(struct Main *bmain, struct ID *id, const int flags);
bool BKE_lib_id_make_local(struct Main *bmain, struct ID *id, const bool test, const int flags);
bool id_single_user(struct bContext *C,
struct ID *id,
struct PointerRNA *ptr,

View File

@ -41,7 +41,7 @@ void BKE_light_copy_data(struct Main *bmain,
const int flag);
struct Light *BKE_light_copy(struct Main *bmain, const struct Light *la) ATTR_WARN_UNUSED_RESULT;
struct Light *BKE_light_localize(struct Light *la) ATTR_WARN_UNUSED_RESULT;
void BKE_light_make_local(struct Main *bmain, struct Light *la, const bool lib_local);
void BKE_light_make_local(struct Main *bmain, struct Light *la, const int flags);
void BKE_light_free(struct Light *la);
#ifdef __cplusplus

View File

@ -40,7 +40,7 @@ void BKE_lightprobe_copy_data(struct Main *bmain,
const struct LightProbe *probe_src,
const int flag);
struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, const struct LightProbe *probe);
void BKE_lightprobe_make_local(struct Main *bmain, struct LightProbe *probe, const bool lib_local);
void BKE_lightprobe_make_local(struct Main *bmain, struct LightProbe *probe, const int flags);
void BKE_lightprobe_free(struct LightProbe *probe);
#ifdef __cplusplus

View File

@ -52,7 +52,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineSt
void BKE_linestyle_make_local(struct Main *bmain,
struct FreestyleLineStyle *linestyle,
const bool lib_local);
const int flags);
FreestyleLineStyle *BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer);

View File

@ -149,7 +149,7 @@ void BKE_mask_copy_data(struct Main *bmain,
struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
struct Mask *BKE_mask_copy(struct Main *bmain, const struct Mask *mask);
void BKE_mask_make_local(struct Main *bmain, struct Mask *mask, const bool lib_local);
void BKE_mask_make_local(struct Main *bmain, struct Mask *mask, const int flags);
void BKE_mask_free(struct Mask *mask);

View File

@ -62,7 +62,7 @@ void BKE_material_copy_data(struct Main *bmain,
const int flag);
struct Material *BKE_material_copy(struct Main *bmain, const struct Material *ma);
struct Material *BKE_material_localize(struct Material *ma);
void BKE_material_make_local(struct Main *bmain, struct Material *ma, const bool lib_local);
void BKE_material_make_local(struct Main *bmain, struct Material *ma, const int flags);
void BKE_gpencil_material_attr_init(struct Material *ma);
/* UNUSED */

View File

@ -45,7 +45,7 @@ void BKE_mball_copy_data(struct Main *bmain,
const int flag);
struct MetaBall *BKE_mball_copy(struct Main *bmain, const struct MetaBall *mb);
void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const bool lib_local);
void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const int flags);
bool BKE_mball_is_any_selected(const struct MetaBall *mb);
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len);

View File

@ -145,7 +145,7 @@ struct Mesh *BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct L
bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me);
bool BKE_mesh_clear_facemap_customdata(struct Mesh *me);
void BKE_mesh_make_local(struct Main *bmain, struct Mesh *me, const bool lib_local);
void BKE_mesh_make_local(struct Main *bmain, struct Mesh *me, const int flags);
float (*BKE_mesh_orco_verts_get(struct Object *ob))[3];
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);

View File

@ -43,7 +43,7 @@ void BKE_movieclip_copy_data(struct Main *bmain,
const struct MovieClip *clip_src,
const int flag);
struct MovieClip *BKE_movieclip_copy(struct Main *bmain, const struct MovieClip *clip);
void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const bool lib_local);
void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const int flags);
struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name);
struct MovieClip *BKE_movieclip_file_add_exists_ex(struct Main *bmain,

View File

@ -399,7 +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, const bool lib_local);
void ntreeMakeLocal(struct Main *bmain, struct bNodeTree *ntree, const int flags);
void ntreeFreeLocalNode(struct bNodeTree *ntree, struct bNode *node);
void ntreeFreeLocalTree(struct bNodeTree *ntree);
struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);

View File

@ -140,11 +140,7 @@ void BKE_object_copy_data(struct Main *bmain,
const struct Object *ob_src,
const int flag);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
void BKE_object_make_local(struct Main *bmain, struct Object *ob, const bool lib_local);
void BKE_object_make_local_ex(struct Main *bmain,
struct Object *ob,
const bool lib_local,
const bool clear_proxy);
void BKE_object_make_local(struct Main *bmain, struct Object *ob, const int flags);
bool BKE_object_is_libdata(const struct Object *ob);
bool BKE_object_obdata_is_libdata(const struct Object *ob);

View File

@ -136,7 +136,7 @@ void BKE_palette_copy_data(struct Main *bmain,
const struct Palette *palette_src,
const int flag);
struct Palette *BKE_palette_copy(struct Main *bmain, const struct Palette *palette);
void BKE_palette_make_local(struct Main *bmain, struct Palette *palette, const bool lib_local);
void BKE_palette_make_local(struct Main *bmain, struct Palette *palette, const int flags);
struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
bool BKE_palette_is_empty(const struct Palette *palette);
void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
@ -150,7 +150,7 @@ void BKE_paint_curve_copy_data(struct Main *bmain,
const struct PaintCurve *pc_src,
const int flag);
struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
void BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const bool lib_local);
void BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const int flags);
bool BKE_paint_ensure(struct ToolSettings *ts, struct Paint **r_paint);
void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3]);

View File

@ -377,7 +377,7 @@ struct ParticleSettings *BKE_particlesettings_copy(struct Main *bmain,
const struct ParticleSettings *part);
void BKE_particlesettings_make_local(struct Main *bmain,
struct ParticleSettings *part,
const bool lib_local);
const int flags);
void psys_reset(struct ParticleSystem *psys, int mode);

View File

@ -117,7 +117,7 @@ void BKE_scene_copy_data(struct Main *bmain,
struct Scene *BKE_scene_copy(struct Main *bmain, struct Scene *sce, int type);
void BKE_scene_groups_relink(struct Scene *sce);
void BKE_scene_make_local(struct Main *bmain, struct Scene *sce, const bool lib_local);
void BKE_scene_make_local(struct Main *bmain, struct Scene *sce, const int flags);
struct Scene *BKE_scene_find_from_collection(const struct Main *bmain,
const struct Collection *collection);

View File

@ -111,7 +111,7 @@ void BKE_sound_copy_data(struct Main *bmain,
const struct bSound *sound_src,
const int flag);
void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const bool lib_local);
void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const int flags);
#if defined(WITH_AUDASPACE)
AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume);

View File

@ -36,7 +36,7 @@ void BKE_speaker_copy_data(struct Main *bmain,
const struct Speaker *spk_src,
const int flag);
struct Speaker *BKE_speaker_copy(struct Main *bmain, const struct Speaker *spk);
void BKE_speaker_make_local(struct Main *bmain, struct Speaker *spk, const bool lib_local);
void BKE_speaker_make_local(struct Main *bmain, struct Speaker *spk, const int flags);
void BKE_speaker_free(struct Speaker *spk);
#ifdef __cplusplus

View File

@ -47,7 +47,7 @@ void BKE_text_copy_data(struct Main *bmain,
const struct Text *ta_src,
const int flag);
struct Text *BKE_text_copy(struct Main *bmain, const struct Text *ta);
void BKE_text_make_local(struct Main *bmain, struct Text *text, const bool lib_local);
void BKE_text_make_local(struct Main *bmain, struct Text *text, const int flags);
void BKE_text_clear(struct Text *text);
void BKE_text_write(struct Text *text, const char *str);
int BKE_text_file_modified_check(struct Text *text);

View File

@ -51,7 +51,7 @@ void BKE_texture_copy_data(struct Main *bmain,
struct Tex *BKE_texture_copy(struct Main *bmain, const struct Tex *tex);
struct Tex *BKE_texture_add(struct Main *bmain, const char *name);
struct Tex *BKE_texture_localize(struct Tex *tex);
void BKE_texture_make_local(struct Main *bmain, struct Tex *tex, const bool lib_local);
void BKE_texture_make_local(struct Main *bmain, struct Tex *tex, const int flags);
void BKE_texture_type_set(struct Tex *tex, int type);
void BKE_texture_mtex_default(struct MTex *mtex);

View File

@ -40,7 +40,7 @@ void BKE_world_copy_data(struct Main *bmain,
const int flag);
struct World *BKE_world_copy(struct Main *bmain, const struct World *wrld);
struct World *BKE_world_localize(struct World *wrld);
void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib_local);
void BKE_world_make_local(struct Main *bmain, struct World *wrld, const int flags);
void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
#ifdef __cplusplus

View File

@ -91,9 +91,9 @@ 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)
void BKE_action_make_local(Main *bmain, bAction *act, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &act->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &act->id, flags);
}
/* .................................. */

View File

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

View File

@ -766,8 +766,9 @@ void BKE_brush_free(Brush *brush)
BKE_previewimg_free(&(brush->preview));
}
void BKE_brush_make_local(Main *bmain, Brush *brush, const bool lib_local)
void BKE_brush_make_local(Main *bmain, Brush *brush, const int flags)
{
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
bool is_local = false, is_lib = false;
/* - only lib users: do nothing (unless force_local is set)
@ -781,7 +782,7 @@ void BKE_brush_make_local(Main *bmain, Brush *brush, const bool lib_local)
if (brush->clone.image) {
/* Special case: ima always local immediately. Clone image should only have one user anyway. */
BKE_lib_id_make_local(bmain, &brush->clone.image->id, false, false);
BKE_lib_id_make_local(bmain, &brush->clone.image->id, false, 0);
}
BKE_library_ID_test_usages(bmain, brush, &is_local, &is_lib);

View File

@ -211,9 +211,9 @@ CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
return cache_file_copy;
}
void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib_local)
void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &cache_file->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &cache_file->id, flags);
}
void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)

View File

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

View File

@ -369,9 +369,9 @@ Collection *BKE_collection_duplicate(Main *bmain,
return collection_new;
}
void BKE_collection_make_local(Main *bmain, Collection *collection, const bool lib_local)
void BKE_collection_make_local(Main *bmain, Collection *collection, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &collection->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &collection->id, flags);
}
/********************************* Naming *******************************/

View File

@ -220,9 +220,9 @@ Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
return cu_copy;
}
void BKE_curve_make_local(Main *bmain, Curve *cu, const bool lib_local)
void BKE_curve_make_local(Main *bmain, Curve *cu, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &cu->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &cu->id, flags);
}
/* Get list of nurbs from editnurbs structure */

View File

@ -325,9 +325,9 @@ VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath)
return BKE_vfont_load_exists_ex(bmain, filepath, NULL);
}
void BKE_vfont_make_local(Main *bmain, VFont *vfont, const bool lib_local)
void BKE_vfont_make_local(Main *bmain, VFont *vfont, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &vfont->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &vfont->id, flags);
}
static VFont *which_vfont(Curve *cu, CharInfo *info)

View File

@ -707,9 +707,9 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
return gpd_dst;
}
void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const bool lib_local)
void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &gpd->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &gpd->id, flags);
}
/* ************************************************** */

View File

@ -462,9 +462,9 @@ Image *BKE_image_copy(Main *bmain, const Image *ima)
return ima_copy;
}
void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local)
void BKE_image_make_local(Main *bmain, Image *ima, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &ima->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &ima->id, flags);
}
void BKE_image_merge(Main *bmain, Image *dest, Image *source)

View File

@ -329,9 +329,9 @@ void BKE_lattice_free(Lattice *lt)
}
}
void BKE_lattice_make_local(Main *bmain, Lattice *lt, const bool lib_local)
void BKE_lattice_make_local(Main *bmain, Lattice *lt, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &lt->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &lt->id, flags);
}
typedef struct LatticeDeformData {

View File

@ -377,8 +377,9 @@ 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 lib_local)
void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
{
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
bool is_local = false, is_lib = false;
/* - only lib users: do nothing (unless force_local is set)
@ -436,8 +437,10 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const bool lib_local)
*
* \return true if the block can be made local.
*/
bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags)
{
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
/* We don't care whether ID is directly or indirectly linked
* in case we are making a whole lib local... */
if (!lib_local && (id->tag & LIB_TAG_INDIRECT)) {
@ -447,152 +450,152 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const bool lib_
switch ((ID_Type)GS(id->name)) {
case ID_SCE:
if (!test) {
BKE_scene_make_local(bmain, (Scene *)id, lib_local);
BKE_scene_make_local(bmain, (Scene *)id, flags);
}
return true;
case ID_OB:
if (!test) {
BKE_object_make_local(bmain, (Object *)id, lib_local);
BKE_object_make_local(bmain, (Object *)id, flags);
}
return true;
case ID_ME:
if (!test) {
BKE_mesh_make_local(bmain, (Mesh *)id, lib_local);
BKE_mesh_make_local(bmain, (Mesh *)id, flags);
}
return true;
case ID_CU:
if (!test) {
BKE_curve_make_local(bmain, (Curve *)id, lib_local);
BKE_curve_make_local(bmain, (Curve *)id, flags);
}
return true;
case ID_MB:
if (!test) {
BKE_mball_make_local(bmain, (MetaBall *)id, lib_local);
BKE_mball_make_local(bmain, (MetaBall *)id, flags);
}
return true;
case ID_MA:
if (!test) {
BKE_material_make_local(bmain, (Material *)id, lib_local);
BKE_material_make_local(bmain, (Material *)id, flags);
}
return true;
case ID_TE:
if (!test) {
BKE_texture_make_local(bmain, (Tex *)id, lib_local);
BKE_texture_make_local(bmain, (Tex *)id, flags);
}
return true;
case ID_IM:
if (!test) {
BKE_image_make_local(bmain, (Image *)id, lib_local);
BKE_image_make_local(bmain, (Image *)id, flags);
}
return true;
case ID_LT:
if (!test) {
BKE_lattice_make_local(bmain, (Lattice *)id, lib_local);
BKE_lattice_make_local(bmain, (Lattice *)id, flags);
}
return true;
case ID_LA:
if (!test) {
BKE_light_make_local(bmain, (Light *)id, lib_local);
BKE_light_make_local(bmain, (Light *)id, flags);
}
return true;
case ID_CA:
if (!test) {
BKE_camera_make_local(bmain, (Camera *)id, lib_local);
BKE_camera_make_local(bmain, (Camera *)id, flags);
}
return true;
case ID_SPK:
if (!test) {
BKE_speaker_make_local(bmain, (Speaker *)id, lib_local);
BKE_speaker_make_local(bmain, (Speaker *)id, flags);
}
return true;
case ID_LP:
if (!test) {
BKE_lightprobe_make_local(bmain, (LightProbe *)id, lib_local);
BKE_lightprobe_make_local(bmain, (LightProbe *)id, flags);
}
return true;
case ID_WO:
if (!test) {
BKE_world_make_local(bmain, (World *)id, lib_local);
BKE_world_make_local(bmain, (World *)id, flags);
}
return true;
case ID_VF:
if (!test) {
BKE_vfont_make_local(bmain, (VFont *)id, lib_local);
BKE_vfont_make_local(bmain, (VFont *)id, flags);
}
return true;
case ID_TXT:
if (!test) {
BKE_text_make_local(bmain, (Text *)id, lib_local);
BKE_text_make_local(bmain, (Text *)id, flags);
}
return true;
case ID_SO:
if (!test) {
BKE_sound_make_local(bmain, (bSound *)id, lib_local);
BKE_sound_make_local(bmain, (bSound *)id, flags);
}
return true;
case ID_GR:
if (!test) {
BKE_collection_make_local(bmain, (Collection *)id, lib_local);
BKE_collection_make_local(bmain, (Collection *)id, flags);
}
return true;
case ID_AR:
if (!test) {
BKE_armature_make_local(bmain, (bArmature *)id, lib_local);
BKE_armature_make_local(bmain, (bArmature *)id, flags);
}
return true;
case ID_AC:
if (!test) {
BKE_action_make_local(bmain, (bAction *)id, lib_local);
BKE_action_make_local(bmain, (bAction *)id, flags);
}
return true;
case ID_NT:
if (!test) {
ntreeMakeLocal(bmain, (bNodeTree *)id, lib_local);
ntreeMakeLocal(bmain, (bNodeTree *)id, flags);
}
return true;
case ID_BR:
if (!test) {
BKE_brush_make_local(bmain, (Brush *)id, lib_local);
BKE_brush_make_local(bmain, (Brush *)id, flags);
}
return true;
case ID_PA:
if (!test) {
BKE_particlesettings_make_local(bmain, (ParticleSettings *)id, lib_local);
BKE_particlesettings_make_local(bmain, (ParticleSettings *)id, flags);
}
return true;
case ID_GD:
if (!test) {
BKE_gpencil_make_local(bmain, (bGPdata *)id, lib_local);
BKE_gpencil_make_local(bmain, (bGPdata *)id, flags);
}
return true;
case ID_MC:
if (!test) {
BKE_movieclip_make_local(bmain, (MovieClip *)id, lib_local);
BKE_movieclip_make_local(bmain, (MovieClip *)id, flags);
}
return true;
case ID_MSK:
if (!test) {
BKE_mask_make_local(bmain, (Mask *)id, lib_local);
BKE_mask_make_local(bmain, (Mask *)id, flags);
}
return true;
case ID_LS:
if (!test) {
BKE_linestyle_make_local(bmain, (FreestyleLineStyle *)id, lib_local);
BKE_linestyle_make_local(bmain, (FreestyleLineStyle *)id, flags);
}
return true;
case ID_PAL:
if (!test) {
BKE_palette_make_local(bmain, (Palette *)id, lib_local);
BKE_palette_make_local(bmain, (Palette *)id, flags);
}
return true;
case ID_PC:
if (!test) {
BKE_paint_curve_make_local(bmain, (PaintCurve *)id, lib_local);
BKE_paint_curve_make_local(bmain, (PaintCurve *)id, flags);
}
return true;
case ID_CF:
if (!test) {
BKE_cachefile_make_local(bmain, (CacheFile *)id, lib_local);
BKE_cachefile_make_local(bmain, (CacheFile *)id, flags);
}
return true;
case ID_WS:
@ -2232,16 +2235,14 @@ void BKE_library_make_local(Main *bmain,
}
else {
/* In this specific case, we do want to make ID local even if it has no local usage yet...
* Note that for objects, we don't want proxy pointers to be cleared yet. This will happen
* down the road in this function.
*/
if (GS(id->name) == ID_OB) {
/* Special case for objects because we don't want proxy pointers to be
* cleared yet. This will happen down the road in this function.
*/
BKE_object_make_local_ex(bmain, (Object *)id, true, false);
}
else {
BKE_lib_id_make_local(bmain, id, false, true);
}
BKE_lib_id_make_local(bmain,
id,
false,
LIB_ID_MAKELOCAL_FULL_LIBRARY |
LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
if (id->newid) {
if (GS(id->newid->name) == ID_OB) {
@ -2344,7 +2345,7 @@ void BKE_library_make_local(Main *bmain,
else {
/* we can switch the proxy'ing from the linked-in to the made-local proxy.
* BKE_object_make_proxy() shouldn't be used here, as it allocates memory that
* was already allocated by BKE_object_make_local_ex() (which called BKE_object_copy). */
* was already allocated by BKE_object_make_local() (which called BKE_object_copy). */
ob_new->proxy = ob->proxy;
ob_new->proxy_group = ob->proxy_group;
ob_new->proxy_from = ob->proxy_from;

View File

@ -129,9 +129,9 @@ Light *BKE_light_localize(Light *la)
return lan;
}
void BKE_light_make_local(Main *bmain, Light *la, const bool lib_local)
void BKE_light_make_local(Main *bmain, Light *la, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &la->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &la->id, flags);
}
void BKE_light_free(Light *la)

View File

@ -101,9 +101,9 @@ LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
return probe_copy;
}
void BKE_lightprobe_make_local(Main *bmain, LightProbe *probe, const bool lib_local)
void BKE_lightprobe_make_local(Main *bmain, LightProbe *probe, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &probe->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &probe->id, flags);
}
void BKE_lightprobe_free(LightProbe *probe)

View File

@ -186,11 +186,9 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineSt
return linestyle_copy;
}
void BKE_linestyle_make_local(struct Main *bmain,
FreestyleLineStyle *linestyle,
const bool lib_local)
void BKE_linestyle_make_local(struct Main *bmain, FreestyleLineStyle *linestyle, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &linestyle->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &linestyle->id, flags);
}
FreestyleLineStyle *BKE_linestyle_active_from_view_layer(ViewLayer *view_layer)

View File

@ -906,9 +906,9 @@ Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
return mask_copy;
}
void BKE_mask_make_local(Main *bmain, Mask *mask, const bool lib_local)
void BKE_mask_make_local(Main *bmain, Mask *mask, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &mask->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &mask->id, flags);
}
void BKE_mask_point_free(MaskSplinePoint *point)

View File

@ -230,9 +230,9 @@ Material *BKE_material_localize(Material *ma)
return man;
}
void BKE_material_make_local(Main *bmain, Material *ma, const bool lib_local)
void BKE_material_make_local(Main *bmain, Material *ma, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &ma->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &ma->id, flags);
}
Material ***BKE_object_material_array(Object *ob)

View File

@ -125,9 +125,9 @@ MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
return mb_copy;
}
void BKE_mball_make_local(Main *bmain, MetaBall *mb, const bool lib_local)
void BKE_mball_make_local(Main *bmain, MetaBall *mb, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &mb->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &mb->id, flags);
}
/* most simple meta-element adding function

View File

@ -836,9 +836,9 @@ Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(BMEditMesh *em,
return me;
}
void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local)
void BKE_mesh_make_local(Main *bmain, Mesh *me, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &me->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &me->id, flags);
}
BoundBox *BKE_mesh_boundbox_get(Object *ob)

View File

@ -1666,9 +1666,9 @@ MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
return clip_copy;
}
void BKE_movieclip_make_local(Main *bmain, MovieClip *clip, const bool lib_local)
void BKE_movieclip_make_local(Main *bmain, MovieClip *clip, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &clip->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &clip->id, flags);
}
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, const bool lib_local)
void ntreeMakeLocal(Main *bmain, bNodeTree *ntree, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &ntree->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &ntree->id, flags);
}
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)

View File

@ -1741,11 +1741,10 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
return obn;
}
void BKE_object_make_local_ex(Main *bmain,
Object *ob,
const bool lib_local,
const bool clear_proxy)
void BKE_object_make_local(Main *bmain, Object *ob, const int flags)
{
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
const bool clear_proxy = (flags & LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING) == 0;
bool is_local = false, is_lib = false;
/* - only lib users: do nothing (unless force_local is set)
@ -1789,11 +1788,6 @@ void BKE_object_make_local_ex(Main *bmain,
}
}
void BKE_object_make_local(Main *bmain, Object *ob, const bool lib_local)
{
BKE_object_make_local_ex(bmain, ob, lib_local, true);
}
/* Returns true if the Object is from an external blend file (libdata) */
bool BKE_object_is_libdata(const Object *ob)
{

View File

@ -517,9 +517,9 @@ PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
return pc_copy;
}
void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local)
void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &pc->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &pc->id, flags);
}
Palette *BKE_paint_palette(Paint *p)
@ -604,9 +604,9 @@ Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
return palette_copy;
}
void BKE_palette_make_local(Main *bmain, Palette *palette, const bool lib_local)
void BKE_palette_make_local(Main *bmain, Palette *palette, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &palette->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &palette->id, flags);
}
void BKE_palette_init(Palette *palette)

View File

@ -3837,9 +3837,9 @@ ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings
return part_copy;
}
void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part, const bool lib_local)
void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &part->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &part->id, flags);
}
/************************************************/

View File

@ -488,11 +488,11 @@ void BKE_scene_groups_relink(Scene *sce)
}
}
void BKE_scene_make_local(Main *bmain, Scene *sce, const bool lib_local)
void BKE_scene_make_local(Main *bmain, Scene *sce, const int flags)
{
/* 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, lib_local);
BKE_lib_id_make_local_generic(bmain, &sce->id, flags);
}
/** Free (or release) any data used by this scene (does not free the scene itself). */

View File

@ -217,9 +217,9 @@ void BKE_sound_copy_data(Main *UNUSED(bmain),
BKE_sound_reset_runtime(sound_dst);
}
void BKE_sound_make_local(Main *bmain, bSound *sound, const bool lib_local)
void BKE_sound_make_local(Main *bmain, bSound *sound, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &sound->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &sound->id, flags);
}
#ifdef WITH_AUDASPACE

View File

@ -74,9 +74,9 @@ Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
return spk_copy;
}
void BKE_speaker_make_local(Main *bmain, Speaker *spk, const bool lib_local)
void BKE_speaker_make_local(Main *bmain, Speaker *spk, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &spk->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &spk->id, flags);
}
void BKE_speaker_free(Speaker *spk)

View File

@ -441,9 +441,9 @@ Text *BKE_text_copy(Main *bmain, const Text *ta)
return ta_copy;
}
void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local)
void BKE_text_make_local(Main *bmain, Text *text, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &text->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &text->id, flags);
}
void BKE_text_clear(Text *text) /* called directly from rna */

View File

@ -386,9 +386,9 @@ Tex *BKE_texture_localize(Tex *tex)
/* ------------------------------------------------------------------------- */
void BKE_texture_make_local(Main *bmain, Tex *tex, const bool lib_local)
void BKE_texture_make_local(Main *bmain, Tex *tex, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &tex->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &tex->id, flags);
}
Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)

View File

@ -154,9 +154,9 @@ World *BKE_world_localize(World *wrld)
return wrldn;
}
void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
void BKE_world_make_local(Main *bmain, World *wrld, const int flags)
{
BKE_lib_id_make_local_generic(bmain, &wrld->id, lib_local);
BKE_lib_id_make_local_generic(bmain, &wrld->id, flags);
}
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)

View File

@ -557,7 +557,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
}
}
else {
if (BKE_lib_id_make_local(bmain, id, false, false)) {
if (BKE_lib_id_make_local(bmain, id, false, 0)) {
BKE_main_id_clear_newpoins(bmain);
/* reassign to get get proper updates/notifiers */
@ -879,8 +879,7 @@ static void template_ID(bContext *C,
UI_but_flag_enable(but, UI_BUT_DISABLED);
}
else {
const bool disabled = (!BKE_lib_id_make_local(
CTX_data_main(C), id, true /* test */, false) ||
const bool disabled = (!BKE_lib_id_make_local(CTX_data_main(C), id, true /* test */, 0) ||
(idfrom && idfrom->lib));
but = uiDefIconBut(block,
UI_BTYPE_BUT,

View File

@ -698,7 +698,7 @@ static void id_local_cb(bContext *C,
Main *bmain = CTX_data_main(C);
/* if the ID type has no special local function,
* just clear the lib */
if (BKE_lib_id_make_local(bmain, tselem->id, false, false) == false) {
if (BKE_lib_id_make_local(bmain, tselem->id, false, 0) == false) {
BKE_lib_id_clear_library_data(bmain, tselem->id);
}
else {

View File

@ -582,13 +582,8 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, bool clear_proxy)
{
/* Special case, as we can't rely on BKE_lib_id_make_local(); it clears proxies. */
if (!clear_proxy && GS(self->name) == ID_OB) {
BKE_object_make_local_ex(bmain, (Object *)self, false, clear_proxy);
}
else {
BKE_lib_id_make_local(bmain, self, false, false);
}
BKE_lib_id_make_local(
bmain, self, false, clear_proxy ? 0 : LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
ID *ret_id = self->newid ? self->newid : self;
BKE_id_clear_newpoin(self);