Cleanup: BKE_library: remove 'test' param of id_copy.

This was used in *one* place only... much better to have a dedicated
helper for that kind of things. ;)
This commit is contained in:
2019-02-04 15:34:31 +01:00
parent 999f3985c0
commit 7636e9785d
52 changed files with 103 additions and 125 deletions

View File

@@ -162,8 +162,9 @@ void BKE_id_clear_newpoin(struct ID *id);
void BKE_id_make_local_generic(struct Main *bmain, struct ID *id, const bool id_in_mainlist, const bool lib_local);
bool id_make_local(struct Main *bmain, struct ID *id, const bool test, const bool force_local);
bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
bool id_copy(struct Main *bmain, const struct ID *id, struct ID **newid, bool test);
bool BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag, const bool test);
bool BKE_id_copy_is_allowed(const struct ID *id);
bool id_copy(struct Main *bmain, const struct ID *id, struct ID **newid);
bool BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag);
void BKE_id_swap(struct Main *bmain, struct ID *id_a, struct ID *id_b);
void id_sort_by_name(struct ListBase *lb, struct ID *id);
void BKE_id_expand_local(struct Main *bmain, struct ID *id);

View File

@@ -163,7 +163,7 @@ void BKE_action_copy_data(Main *UNUSED(bmain), bAction *act_dst, const bAction *
bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
{
bAction *act_copy;
BKE_id_copy_ex(bmain, &act_src->id, (ID **)&act_copy, 0, false);
BKE_id_copy_ex(bmain, &act_src->id, (ID **)&act_copy, 0);
return act_copy;
}

View File

@@ -284,8 +284,8 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
/* make a copy of action - at worst, user has to delete copies... */
if (do_action) {
BLI_assert(bmain != NULL);
BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, 0, false);
BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, 0, false);
BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, 0);
BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, 0);
}
else if (do_id_user) {
id_us_plus((ID *)dadt->action);

View File

@@ -201,7 +201,7 @@ void BKE_armature_copy_data(Main *UNUSED(bmain), bArmature *arm_dst, const bArma
bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
{
bArmature *arm_copy;
BKE_id_copy_ex(bmain, &arm->id, (ID **)&arm_copy, 0, false);
BKE_id_copy_ex(bmain, &arm->id, (ID **)&arm_copy, 0);
return arm_copy;
}

View File

@@ -590,7 +590,7 @@ void BKE_brush_copy_data(Main *UNUSED(bmain), Brush *brush_dst, const Brush *bru
Brush *BKE_brush_copy(Main *bmain, const Brush *brush)
{
Brush *brush_copy;
BKE_id_copy_ex(bmain, &brush->id, (ID **)&brush_copy, 0, false);
BKE_id_copy_ex(bmain, &brush->id, (ID **)&brush_copy, 0);
return brush_copy;
}

View File

@@ -126,7 +126,7 @@ void BKE_cachefile_copy_data(
CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
{
CacheFile *cache_file_copy;
BKE_id_copy_ex(bmain, &cache_file->id, (ID **)&cache_file_copy, 0, false);
BKE_id_copy_ex(bmain, &cache_file->id, (ID **)&cache_file_copy, 0);
return cache_file_copy;
}

View File

@@ -103,7 +103,7 @@ void BKE_camera_copy_data(Main *UNUSED(bmain), Camera *cam_dst, const Camera *ca
Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
{
Camera *cam_copy;
BKE_id_copy_ex(bmain, &cam->id, (ID **)&cam_copy, 0, false);
BKE_id_copy_ex(bmain, &cam->id, (ID **)&cam_copy, 0);
return cam_copy;
}

View File

@@ -224,7 +224,7 @@ Collection *BKE_collection_copy(Main *bmain, Collection *parent, Collection *col
}
Collection *collection_new;
BKE_id_copy_ex(bmain, &collection->id, (ID **)&collection_new, 0, false);
BKE_id_copy_ex(bmain, &collection->id, (ID **)&collection_new, 0);
id_us_min(&collection_new->id); /* Copying add one user by default, need to get rid of that one. */
/* Optionally add to parent. */

View File

@@ -206,7 +206,7 @@ void BKE_curve_copy_data(Main *bmain, Curve *cu_dst, const Curve *cu_src, const
cu_dst->batch_cache = NULL;
if (cu_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
BKE_id_copy_ex(bmain, &cu_src->key->id, (ID **)&cu_dst->key, flag, false);
BKE_id_copy_ex(bmain, &cu_src->key->id, (ID **)&cu_dst->key, flag);
}
cu_dst->editnurb = NULL;
@@ -216,7 +216,7 @@ void BKE_curve_copy_data(Main *bmain, Curve *cu_dst, const Curve *cu_src, const
Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
{
Curve *cu_copy;
BKE_id_copy_ex(bmain, &cu->id, (ID **)&cu_copy, LIB_ID_COPY_SHAPEKEY, false);
BKE_id_copy_ex(bmain, &cu->id, (ID **)&cu_copy, LIB_ID_COPY_SHAPEKEY);
return cu_copy;
}

View File

@@ -1001,8 +1001,7 @@ static void curve_calc_modifiers_post(
Mesh *temp_mesh;
BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
BKE_id_free(NULL, modified);
modified = temp_mesh;
@@ -1047,8 +1046,7 @@ static void curve_calc_modifiers_post(
Mesh *temp_mesh;
BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
BKE_id_free(NULL, modified);
modified = temp_mesh;

View File

@@ -637,7 +637,7 @@ void BKE_gpencil_copy_data(bGPdata *gpd_dst, const bGPdata *gpd_src, const int U
bGPdata *BKE_gpencil_copy(Main *bmain, const bGPdata *gpd)
{
bGPdata *gpd_copy;
BKE_id_copy_ex(bmain, &gpd->id, (ID **)&gpd_copy, 0, false);
BKE_id_copy_ex(bmain, &gpd->id, (ID **)&gpd_copy, 0);
return gpd_copy;
}
@@ -662,7 +662,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
}
else {
BLI_assert(bmain != NULL);
BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_dst, 0, false);
BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_dst, 0);
}
/* Copy internal data (layers, etc.) */

View File

@@ -420,7 +420,7 @@ void BKE_image_copy_data(Main *UNUSED(bmain), Image *ima_dst, const Image *ima_s
Image *BKE_image_copy(Main *bmain, const Image *ima)
{
Image *ima_copy;
BKE_id_copy_ex(bmain, &ima->id, (ID **)&ima_copy, 0, false);
BKE_id_copy_ex(bmain, &ima->id, (ID **)&ima_copy, 0);
return ima_copy;
}

View File

@@ -179,7 +179,7 @@ void BKE_key_copy_data(Main *UNUSED(bmain), Key *key_dst, const Key *key_src, co
Key *BKE_key_copy(Main *bmain, const Key *key)
{
Key *key_copy;
BKE_id_copy_ex(bmain, &key->id, (ID **)&key_copy, 0, false);
BKE_id_copy_ex(bmain, &key->id, (ID **)&key_copy, 0);
return key_copy;
}

View File

@@ -110,7 +110,7 @@ void BKE_lamp_copy_data(Main *bmain, Lamp *la_dst, const Lamp *la_src, const int
if (la_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag);
}
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
@@ -124,7 +124,7 @@ void BKE_lamp_copy_data(Main *bmain, Lamp *la_dst, const Lamp *la_src, const int
Lamp *BKE_lamp_copy(Main *bmain, const Lamp *la)
{
Lamp *la_copy;
BKE_id_copy_ex(bmain, &la->id, (ID **)&la_copy, 0, false);
BKE_id_copy_ex(bmain, &la->id, (ID **)&la_copy, 0);
return la_copy;
}

View File

@@ -277,7 +277,7 @@ void BKE_lattice_copy_data(Main *bmain, Lattice *lt_dst, const Lattice *lt_src,
lt_dst->def = MEM_dupallocN(lt_src->def);
if (lt_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
BKE_id_copy_ex(bmain, &lt_src->key->id, (ID **)&lt_dst->key, flag, false);
BKE_id_copy_ex(bmain, &lt_src->key->id, (ID **)&lt_dst->key, flag);
}
if (lt_src->dvert) {
@@ -292,7 +292,7 @@ void BKE_lattice_copy_data(Main *bmain, Lattice *lt_dst, const Lattice *lt_src,
Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt)
{
Lattice *lt_copy;
BKE_id_copy_ex(bmain, &lt->id, (ID **)&lt_copy, LIB_ID_COPY_SHAPEKEY, false);
BKE_id_copy_ex(bmain, &lt->id, (ID **)&lt_copy, LIB_ID_COPY_SHAPEKEY);
return lt_copy;
}

View File

@@ -341,7 +341,7 @@ void BKE_id_make_local_generic(Main *bmain, ID *id, const bool id_in_mainlist, c
ID *id_new;
/* Should not fail in expected usecases, but id_copy does not copy Scene e.g. */
if (id_copy(bmain, id, &id_new, false)) {
if (id_copy(bmain, id, &id_new)) {
id_new->us = 0;
/* setting newid is mandatory for complex make_lib_local logic... */
@@ -538,6 +538,16 @@ static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
}
}
bool BKE_id_copy_is_allowed(const ID *id)
{
#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
ID_IP /* Deprecated */
return !ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY);
#undef LIB_ID_TYPES_NOCOPY
}
/**
* Generic entry point for copying a datablock (new API).
*
@@ -550,24 +560,17 @@ static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
* \param id: Source datablock.
* \param r_newid: Pointer to new (copied) ID pointer.
* \param flag: Set of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
* \param test: If set, do not do any copy, just test whether copy is supported.
* \return False when copying that ID type is not supported, true otherwise.
*/
/* XXX TODO remove test thing, *all* IDs should be copyable that way! */
bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, const bool test)
bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
{
#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
ID_IP /* Deprecated */
BLI_assert(test || (r_newid != NULL));
BLI_assert(r_newid != NULL);
/* Make sure destination pointer is all good. */
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) {
if (r_newid != NULL) {
*r_newid = NULL;
}
*r_newid = NULL;
}
else {
if (r_newid != NULL && *r_newid != NULL) {
if (*r_newid != NULL) {
/* Allow some garbage non-initialized memory to go in, and clean it up here. */
const size_t size = BKE_libblock_get_alloc_info(GS(id->name), NULL);
memset(*r_newid, 0, size);
@@ -578,12 +581,9 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
if (id == NULL) {
return false;
}
if (ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY)) {
if (!BKE_id_copy_is_allowed(id)) {
return false;
}
else if (test) {
return true;
}
BKE_libblock_copy_ex(bmain, id, r_newid, flag);
@@ -713,9 +713,9 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
* Invokes the appropriate copy method for the block and returns the result in
* newid, unless test. Returns true if the block can be copied.
*/
bool id_copy(Main *bmain, const ID *id, ID **newid, bool test)
bool id_copy(Main *bmain, const ID *id, ID **newid)
{
return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_SHAPEKEY, test);
return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_SHAPEKEY);
}
/** Does a mere memory swap over the whole IDs data (including type-specific memory).
@@ -797,7 +797,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
/* if property isn't editable, we're going to have an extra block hanging around until we save */
if (RNA_property_editable(ptr, prop)) {
Main *bmain = CTX_data_main(C);
if (id_copy(bmain, id, &newid, false) && newid) {
if (id_copy(bmain, id, &newid) && newid) {
/* copy animation actions too */
BKE_animdata_copy_id_action(bmain, id, false);
/* us is 1 by convention with new IDs, but RNA_property_pointer_set

View File

@@ -164,7 +164,7 @@ static ID *override_static_create_from(Main *bmain, ID *reference_id)
{
ID *local_id;
if (!id_copy(bmain, reference_id, (ID **)&local_id, false)) {
if (!id_copy(bmain, reference_id, (ID **)&local_id)) {
return NULL;
}
id_us_min(local_id);
@@ -621,7 +621,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
* a (performances) issue here. */
ID *tmp_id;
id_copy(bmain, local->override_static->reference, &tmp_id, false);
id_copy(bmain, local->override_static->reference, &tmp_id);
if (tmp_id == NULL) {
return;
@@ -727,7 +727,7 @@ ID *BKE_override_static_operations_store_start(Main *bmain, OverrideStaticStorag
/* This would imply change in handling of usercout all over RNA (and possibly all over Blender code).
* Not impossible to do, but would rather see first is extra useless usual user handling is actually
* a (performances) issue here, before doing it. */
id_copy((Main *)override_storage, local, &storage_id, false);
id_copy((Main *)override_storage, local, &storage_id);
if (storage_id != NULL) {
PointerRNA rnaptr_reference, rnaptr_final, rnaptr_storage;

View File

@@ -76,7 +76,7 @@ void BKE_lightprobe_copy_data(
LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
{
LightProbe *probe_copy;
BKE_id_copy_ex(bmain, &probe->id, (ID **)&probe_copy, 0, false);
BKE_id_copy_ex(bmain, &probe->id, (ID **)&probe_copy, 0);
return probe_copy;
}

View File

@@ -170,7 +170,7 @@ void BKE_linestyle_copy_data(
if (linestyle_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)linestyle_src->nodetree, (ID **)&linestyle_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)linestyle_src->nodetree, (ID **)&linestyle_dst->nodetree, flag);
}
LineStyleModifier *m;
@@ -195,7 +195,7 @@ void BKE_linestyle_copy_data(
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle)
{
FreestyleLineStyle *linestyle_copy;
BKE_id_copy_ex(bmain, &linestyle->id, (ID **)&linestyle_copy, 0, false);
BKE_id_copy_ex(bmain, &linestyle->id, (ID **)&linestyle_copy, 0);
return linestyle_copy;
}

View File

@@ -863,7 +863,7 @@ void BKE_mask_copy_data(Main *UNUSED(bmain), Mask *mask_dst, const Mask *mask_sr
Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
{
Mask *mask_copy;
BKE_id_copy_ex(bmain, &mask->id, (ID **)&mask_copy, 0, false);
BKE_id_copy_ex(bmain, &mask->id, (ID **)&mask_copy, 0);
return mask_copy;
}

View File

@@ -184,7 +184,7 @@ void BKE_material_copy_data(Main *bmain, Material *ma_dst, const Material *ma_sr
if (ma_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)ma_src->nodetree, (ID **)&ma_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)ma_src->nodetree, (ID **)&ma_dst->nodetree, flag);
}
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
@@ -210,7 +210,7 @@ void BKE_material_copy_data(Main *bmain, Material *ma_dst, const Material *ma_sr
Material *BKE_material_copy(Main *bmain, const Material *ma)
{
Material *ma_copy;
BKE_id_copy_ex(bmain, &ma->id, (ID **)&ma_copy, 0, false);
BKE_id_copy_ex(bmain, &ma->id, (ID **)&ma_copy, 0);
return ma_copy;
}

View File

@@ -116,7 +116,7 @@ void BKE_mball_copy_data(Main *UNUSED(bmain), MetaBall *mb_dst, const MetaBall *
MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
{
MetaBall *mb_copy;
BKE_id_copy_ex(bmain, &mb->id, (ID **)&mb_copy, 0, false);
BKE_id_copy_ex(bmain, &mb->id, (ID **)&mb_copy, 0);
return mb_copy;
}

View File

@@ -572,7 +572,7 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
/* TODO Do we want to add flag to prevent this? */
if (me_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
BKE_id_copy_ex(bmain, &me_src->key->id, (ID **)&me_dst->key, flag, false);
BKE_id_copy_ex(bmain, &me_src->key->id, (ID **)&me_dst->key, flag);
}
}
@@ -701,14 +701,14 @@ Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
}
Mesh *result;
BKE_id_copy_ex(NULL, &source->id, (ID **)&result, flags, false);
BKE_id_copy_ex(NULL, &source->id, (ID **)&result, flags);
return result;
}
Mesh *BKE_mesh_copy(Main *bmain, const Mesh *me)
{
Mesh *me_copy;
BKE_id_copy_ex(bmain, &me->id, (ID **)&me_copy, LIB_ID_COPY_SHAPEKEY, false);
BKE_id_copy_ex(bmain, &me->id, (ID **)&me_copy, LIB_ID_COPY_SHAPEKEY);
return me_copy;
}

View File

@@ -863,7 +863,7 @@ Mesh *BKE_mesh_new_from_object(
/* copies object and modifiers (but not the data) */
Object *tmpobj;
/* TODO: make it temp copy outside bmain! */
BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES | LIB_ID_CREATE_NO_DEG_TAG, false);
BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES | LIB_ID_CREATE_NO_DEG_TAG);
tmpcu = (Curve *)tmpobj->data;
/* Copy cached display list, it might be needed by the stack evaluation.
@@ -884,7 +884,7 @@ Mesh *BKE_mesh_new_from_object(
BKE_object_free_modifiers(tmpobj, 0);
/* copies the data */
BKE_id_copy_ex(bmain, ob->data, (ID **)&copycu, LIB_ID_CREATE_NO_DEG_TAG, false);
BKE_id_copy_ex(bmain, ob->data, (ID **)&copycu, LIB_ID_CREATE_NO_DEG_TAG);
id_us_min(tmpobj->data);
tmpobj->data = copycu;
@@ -971,7 +971,7 @@ Mesh *BKE_mesh_new_from_object(
if (cage) {
/* copies the data */
Mesh *mesh = ob->data;
BKE_id_copy_ex(bmain, &mesh->id, (ID **)&tmpmesh, 0, false);
BKE_id_copy_ex(bmain, &mesh->id, (ID **)&tmpmesh, 0);
/* XXX BKE_mesh_copy() already handles materials usercount. */
do_mat_id_data_us = false;
}
@@ -1146,8 +1146,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
BKE_mesh_apply_vert_coords(result, deformedVerts);
if (build_shapekey_layers)
@@ -1162,8 +1161,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
if (build_shapekey_layers)
add_shapekey_layers(mesh_temp, me);

View File

@@ -1525,7 +1525,7 @@ void BKE_movieclip_copy_data(Main *UNUSED(bmain), MovieClip *clip_dst, const Mov
MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
{
MovieClip *clip_copy;
BKE_id_copy_ex(bmain, &clip->id, (ID **)&clip_copy, 0, false);
BKE_id_copy_ex(bmain, &clip->id, (ID **)&clip_copy, 0);
return clip_copy;
}

View File

@@ -184,7 +184,7 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain, NlaStrip *strip, const bool use_same_ac
}
else {
/* use a copy of the action instead (user count shouldn't have changed yet) */
BKE_id_copy_ex(bmain, &strip_d->act->id, (ID **)&strip_d->act, flag, false);
BKE_id_copy_ex(bmain, &strip_d->act->id, (ID **)&strip_d->act, flag);
}
}

View File

@@ -1378,7 +1378,7 @@ bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_i
{
bNodeTree *ntree_copy;
const int flag = do_id_user ? LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN : 0;
BKE_id_copy_ex(bmain, (ID *)ntree, (ID **)&ntree_copy, flag, false);
BKE_id_copy_ex(bmain, (ID *)ntree, (ID **)&ntree_copy, flag);
return ntree_copy;
}
bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree)
@@ -2038,8 +2038,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
(LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_COPY_NO_PREVIEW |
LIB_ID_COPY_NO_ANIMDATA),
false);
LIB_ID_COPY_NO_ANIMDATA));
for (node = ltree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP && node->id) {

View File

@@ -1425,7 +1425,7 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
Object *BKE_object_copy(Main *bmain, const Object *ob)
{
Object *ob_copy;
BKE_id_copy_ex(bmain, &ob->id, (ID **)&ob_copy, 0, false);
BKE_id_copy_ex(bmain, &ob->id, (ID **)&ob_copy, 0);
/* We increase object user count when linking to Collections. */
id_us_min(&ob_copy->id);

View File

@@ -445,7 +445,7 @@ void BKE_paint_curve_copy_data(Main *UNUSED(bmain), PaintCurve *pc_dst, const Pa
PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
{
PaintCurve *pc_copy;
BKE_id_copy_ex(bmain, &pc->id, (ID **)&pc_copy, 0, false);
BKE_id_copy_ex(bmain, &pc->id, (ID **)&pc_copy, 0);
return pc_copy;
}
@@ -526,7 +526,7 @@ void BKE_palette_copy_data(Main *UNUSED(bmain), Palette *palette_dst, const Pale
Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
{
Palette *palette_copy;
BKE_id_copy_ex(bmain, &palette->id, (ID **)&palette_copy, 0, false);
BKE_id_copy_ex(bmain, &palette->id, (ID **)&palette_copy, 0);
return palette_copy;
}

View File

@@ -3326,7 +3326,7 @@ void BKE_particlesettings_copy_data(
ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings *part)
{
ParticleSettings *part_copy;
BKE_id_copy_ex(bmain, &part->id, (ID **)&part_copy, 0, false);
BKE_id_copy_ex(bmain, &part->id, (ID **)&part_copy, 0);
return part_copy;
}

View File

@@ -863,8 +863,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
BKE_mesh_tessface_ensure(mesh);
@@ -915,8 +914,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
BKE_mesh_tessface_ensure(mesh);

View File

@@ -3200,8 +3200,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
deformedVerts = BKE_mesh_vertexCos_get(psys->hair_out_mesh, NULL);
clothModifier_do(psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_mesh, deformedVerts);
BKE_mesh_apply_vert_coords(psys->hair_out_mesh, deformedVerts);
@@ -4199,8 +4198,7 @@ static ParticleSettings *particle_settings_localize(ParticleSettings *particle_s
(LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_CACHES),
false);
LIB_ID_COPY_CACHES));
return particle_settings_local;
}

View File

@@ -264,7 +264,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
if (sce_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)sce_src->nodetree, (ID **)&sce_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)sce_src->nodetree, (ID **)&sce_dst->nodetree, flag);
BKE_libblock_relink_ex(bmain, sce_dst->nodetree, (void *)(&sce_src->id), &sce_dst->id, false);
}
@@ -387,7 +387,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
return sce_copy;
}
else {
BKE_id_copy_ex(bmain, (ID *)sce, (ID **)&sce_copy, LIB_ID_COPY_ACTIONS, false);
BKE_id_copy_ex(bmain, (ID *)sce, (ID **)&sce_copy, LIB_ID_COPY_ACTIONS);
id_us_min(&sce_copy->id);
id_us_ensure_real(&sce_copy->id);
@@ -400,7 +400,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
if (lineset->linestyle) {
id_us_min(&lineset->linestyle->id);
/* XXX Not copying anim/actions here? */
BKE_id_copy_ex(bmain, (ID *)lineset->linestyle, (ID **)&lineset->linestyle, 0, false);
BKE_id_copy_ex(bmain, (ID *)lineset->linestyle, (ID **)&lineset->linestyle, 0);
}
}
}
@@ -408,7 +408,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
/* Full copy of world (included animations) */
if (sce_copy->world) {
id_us_min(&sce_copy->world->id);
BKE_id_copy_ex(bmain, (ID *)sce_copy->world, (ID **)&sce_copy->world, LIB_ID_COPY_ACTIONS, false);
BKE_id_copy_ex(bmain, (ID *)sce_copy->world, (ID **)&sce_copy->world, LIB_ID_COPY_ACTIONS);
}
/* Collections */
@@ -418,7 +418,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
/* XXX Not copying anim/actions here? */
if (sce_copy->gpd) {
id_us_min(&sce_copy->gpd->id);
BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, 0, false);
BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, 0);
}
}
else {

View File

@@ -75,7 +75,7 @@ void BKE_speaker_copy_data(Main *UNUSED(bmain), Speaker *UNUSED(spk_dst), const
Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
{
Speaker *spk_copy;
BKE_id_copy_ex(bmain, &spk->id, (ID **)&spk_copy, 0, false);
BKE_id_copy_ex(bmain, &spk->id, (ID **)&spk_copy, 0);
return spk_copy;
}

View File

@@ -496,7 +496,7 @@ void BKE_text_copy_data(Main *UNUSED(bmain), Text *ta_dst, const Text *ta_src, c
Text *BKE_text_copy(Main *bmain, const Text *ta)
{
Text *ta_copy;
BKE_id_copy_ex(bmain, &ta->id, (ID **)&ta_copy, 0, false);
BKE_id_copy_ex(bmain, &ta->id, (ID **)&ta_copy, 0);
return ta_copy;
}

View File

@@ -432,7 +432,7 @@ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const
}
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag);
}
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
@@ -446,7 +446,7 @@ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const
Tex *BKE_texture_copy(Main *bmain, const Tex *tex)
{
Tex *tex_copy;
BKE_id_copy_ex(bmain, &tex->id, (ID **)&tex_copy, 0, false);
BKE_id_copy_ex(bmain, &tex->id, (ID **)&tex_copy, 0);
return tex_copy;
}

View File

@@ -108,7 +108,7 @@ void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, co
if (wrld_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
BKE_id_copy_ex(bmain, (ID *)wrld_src->nodetree, (ID **)&wrld_dst->nodetree, flag, false);
BKE_id_copy_ex(bmain, (ID *)wrld_src->nodetree, (ID **)&wrld_dst->nodetree, flag);
}
BLI_listbase_clear(&wrld_dst->gpumaterial);
@@ -125,7 +125,7 @@ void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, co
World *BKE_world_copy(Main *bmain, const World *wrld)
{
World *wrld_copy;
BKE_id_copy_ex(bmain, &wrld->id, (ID **)&wrld_copy, 0, false);
BKE_id_copy_ex(bmain, &wrld->id, (ID **)&wrld_copy, 0);
return wrld_copy;
}

View File

@@ -287,8 +287,7 @@ Mesh *bc_get_mesh_copy(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
if (triangulate) {
bc_triangulate_mesh(tmpmesh);

View File

@@ -294,8 +294,7 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_ALLOCATE |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_CACHES),
false);
LIB_ID_COPY_CACHES));
#ifdef NESTED_ID_NASTY_WORKAROUND
if (result) {
@@ -325,8 +324,7 @@ bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_ALLOCATE |
LIB_ID_CREATE_NO_DEG_TAG,
false);
LIB_ID_CREATE_NO_DEG_TAG);
#ifdef NESTED_ID_NASTY_WORKAROUND
if (result) {

View File

@@ -733,8 +733,7 @@ static void template_ID(
but->flag |= UI_BUT_UNDO;
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ALONE));
if (/* test only */
(id_copy(CTX_data_main(C), id, NULL, true) == false) ||
if ((!BKE_id_copy_is_allowed(id)) ||
(idfrom && idfrom->lib) ||
(!editable) ||
/* object in editmode - don't change data */

View File

@@ -722,8 +722,7 @@ static bool remap_hair_emitter(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
/* BMESH_ONLY, deform dm may not have tessface */
BKE_mesh_tessface_ensure(mesh);
@@ -1104,8 +1103,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
BKE_mesh_calc_normals(psmd->mesh_final);
BKE_mesh_tessface_ensure(psmd->mesh_final);

View File

@@ -363,8 +363,10 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
{
ID *newid;
if (id_copy(bmain, id, &newid, false)) {
if (newid) id_us_min(newid);
if (id_copy(bmain, id, &newid)) {
if (newid != NULL) {
id_us_min(newid);
}
return newid;
}

View File

@@ -115,8 +115,7 @@ static Mesh *get_quick_mesh(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
float imat[4][4];
float omat[4][4];

View File

@@ -92,8 +92,7 @@ static void deformVerts(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
/* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c

View File

@@ -112,8 +112,7 @@ static void deformVerts(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
if (!ob->pd) {

View File

@@ -182,8 +182,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
BKE_reports_init(&reports, RPT_STORE);

View File

@@ -122,8 +122,7 @@ static Mesh *applyModifier(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
}

View File

@@ -416,8 +416,7 @@ static Mesh *normalEditModifier_do(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
else {
result = mesh;

View File

@@ -388,8 +388,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
cfra_for_cache = cfra_scene;

View File

@@ -119,8 +119,7 @@ static void deformVerts(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
}
else {
surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false);

View File

@@ -190,8 +190,7 @@ Mesh *MOD_deform_mesh_eval_get(
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW |
LIB_ID_COPY_CD_REFERENCE),
false);
LIB_ID_COPY_CD_REFERENCE));
mesh->runtime.deformed_only = 1;
}

View File

@@ -495,8 +495,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
LIB_ID_COPY_NO_PREVIEW);
const int numVerts = result->totvert;
const int numEdges = result->totedge;