Refactor `BKE_id_copy` to return the new ID pointer.
No reasons to keep the new ID pointer as parameter here. Part of T71219.
This commit is contained in:
parent
7c9131d11e
commit
03ef0cfe3c
|
@ -237,7 +237,7 @@ bool id_single_user(struct bContext *C,
|
|||
struct PointerRNA *ptr,
|
||||
struct PropertyRNA *prop);
|
||||
bool BKE_id_copy_is_allowed(const struct ID *id);
|
||||
bool BKE_id_copy(struct Main *bmain, const struct ID *id, struct ID **newid);
|
||||
struct ID *BKE_id_copy(struct Main *bmain, const struct ID *id);
|
||||
struct ID *BKE_id_copy_ex(struct Main *bmain,
|
||||
const struct ID *id,
|
||||
struct ID **r_newid,
|
||||
|
|
|
@ -312,9 +312,7 @@ bAction *BKE_action_add(Main *bmain, const char name[])
|
|||
|
||||
bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
|
||||
{
|
||||
bAction *act_copy;
|
||||
BKE_id_copy(bmain, &act_src->id, (ID **)&act_copy);
|
||||
return act_copy;
|
||||
return (bAction *)BKE_id_copy(bmain, &act_src->id);
|
||||
}
|
||||
|
||||
/* *************** Action Groups *************** */
|
||||
|
|
|
@ -428,9 +428,7 @@ static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst)
|
|||
|
||||
bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
|
||||
{
|
||||
bArmature *arm_copy;
|
||||
BKE_id_copy(bmain, &arm->id, (ID **)&arm_copy);
|
||||
return arm_copy;
|
||||
return (bArmature *)BKE_id_copy(bmain, &arm->id);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -1533,9 +1533,7 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mo
|
|||
|
||||
Brush *BKE_brush_copy(Main *bmain, const Brush *brush)
|
||||
{
|
||||
Brush *brush_copy;
|
||||
BKE_id_copy(bmain, &brush->id, (ID **)&brush_copy);
|
||||
return brush_copy;
|
||||
return (Brush *)BKE_id_copy(bmain, &brush->id);
|
||||
}
|
||||
|
||||
void BKE_brush_debug_print_state(Brush *br)
|
||||
|
|
|
@ -256,9 +256,7 @@ void *BKE_cachefile_add(Main *bmain, const char *name)
|
|||
|
||||
CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
|
||||
{
|
||||
CacheFile *cache_file_copy;
|
||||
BKE_id_copy(bmain, &cache_file->id, (ID **)&cache_file_copy);
|
||||
return cache_file_copy;
|
||||
return (CacheFile *)BKE_id_copy(bmain, &cache_file->id);
|
||||
}
|
||||
|
||||
void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)
|
||||
|
|
|
@ -222,9 +222,7 @@ void *BKE_camera_add(Main *bmain, const char *name)
|
|||
|
||||
Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
|
||||
{
|
||||
Camera *cam_copy;
|
||||
BKE_id_copy(bmain, &cam->id, (ID **)&cam_copy);
|
||||
return cam_copy;
|
||||
return (Camera *)BKE_id_copy(bmain, &cam->id);
|
||||
}
|
||||
|
||||
/* get the camera's dof value, takes the dof object into account */
|
||||
|
|
|
@ -427,9 +427,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
|
|||
|
||||
Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
|
||||
{
|
||||
Curve *cu_copy;
|
||||
BKE_id_copy(bmain, &cu->id, (ID **)&cu_copy);
|
||||
return cu_copy;
|
||||
return (Curve *)BKE_id_copy(bmain, &cu->id);
|
||||
}
|
||||
|
||||
/* Get list of nurbs from editnurbs structure */
|
||||
|
|
|
@ -980,9 +980,7 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
|
|||
*/
|
||||
bGPdata *BKE_gpencil_copy(Main *bmain, const bGPdata *gpd)
|
||||
{
|
||||
bGPdata *gpd_copy;
|
||||
BKE_id_copy(bmain, &gpd->id, (ID **)&gpd_copy);
|
||||
return gpd_copy;
|
||||
return (bGPdata *)BKE_id_copy(bmain, &gpd->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1009,7 +1007,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
|
|||
}
|
||||
else {
|
||||
BLI_assert(bmain != NULL);
|
||||
BKE_id_copy(bmain, &gpd_src->id, (ID **)&gpd_dst);
|
||||
gpd_dst = (bGPdata *)BKE_id_copy(bmain, &gpd_src->id);
|
||||
}
|
||||
|
||||
/* Copy internal data (layers, etc.) */
|
||||
|
|
|
@ -253,9 +253,7 @@ void *BKE_hair_add(Main *bmain, const char *name)
|
|||
|
||||
Hair *BKE_hair_copy(Main *bmain, const Hair *hair)
|
||||
{
|
||||
Hair *hair_copy;
|
||||
BKE_id_copy(bmain, &hair->id, (ID **)&hair_copy);
|
||||
return hair_copy;
|
||||
return (Hair *)BKE_id_copy(bmain, &hair->id);
|
||||
}
|
||||
|
||||
BoundBox *BKE_hair_boundbox_get(Object *ob)
|
||||
|
|
|
@ -603,9 +603,7 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
|
|||
/* empty image block, of similar type and filename */
|
||||
Image *BKE_image_copy(Main *bmain, const Image *ima)
|
||||
{
|
||||
Image *ima_copy;
|
||||
BKE_id_copy(bmain, &ima->id, (ID **)&ima_copy);
|
||||
return ima_copy;
|
||||
return (Image *)BKE_id_copy(bmain, &ima->id);
|
||||
}
|
||||
|
||||
void BKE_image_merge(Main *bmain, Image *dest, Image *source)
|
||||
|
|
|
@ -298,9 +298,7 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
|
|||
|
||||
Key *BKE_key_copy(Main *bmain, const Key *key)
|
||||
{
|
||||
Key *key_copy;
|
||||
BKE_id_copy(bmain, &key->id, (ID **)&key_copy);
|
||||
return key_copy;
|
||||
return (Key *)BKE_id_copy(bmain, &key->id);
|
||||
}
|
||||
|
||||
/* XXX TODO get rid of this! */
|
||||
|
|
|
@ -403,9 +403,7 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
|
|||
|
||||
Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt)
|
||||
{
|
||||
Lattice *lt_copy;
|
||||
BKE_id_copy(bmain, <->id, (ID **)<_copy);
|
||||
return lt_copy;
|
||||
return (Lattice *)BKE_id_copy(bmain, <->id);
|
||||
}
|
||||
|
||||
bool object_deform_mball(Object *ob, ListBase *dispbase)
|
||||
|
|
|
@ -414,11 +414,11 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
|
|||
BKE_lib_id_expand_local(bmain, id);
|
||||
}
|
||||
else {
|
||||
ID *id_new;
|
||||
ID *id_new = BKE_id_copy(bmain, id);
|
||||
|
||||
/* Should not fail in expected use cases,
|
||||
* but a few ID types cannot be copied (LIB, WM, SCR...). */
|
||||
if (BKE_id_copy(bmain, id, &id_new)) {
|
||||
if (id_new != NULL) {
|
||||
id_new->us = 0;
|
||||
|
||||
/* setting newid is mandatory for complex make_lib_local logic... */
|
||||
|
@ -614,9 +614,9 @@ ID *BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
|||
* 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 BKE_id_copy(Main *bmain, const ID *id, ID **newid)
|
||||
ID *BKE_id_copy(Main *bmain, const ID *id)
|
||||
{
|
||||
return (BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_DEFAULT) != NULL);
|
||||
return BKE_id_copy_ex(bmain, id, NULL, LIB_ID_COPY_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -634,8 +634,7 @@ ID *BKE_id_copy_for_duplicate(Main *bmain, ID *id, const eDupli_ID_Flags duplica
|
|||
return id;
|
||||
}
|
||||
|
||||
ID *id_new;
|
||||
BKE_id_copy(bmain, id, &id_new);
|
||||
ID *id_new = BKE_id_copy(bmain, id);
|
||||
/* Copying add one user by default, need to get rid of that one. */
|
||||
id_us_min(id_new);
|
||||
ID_NEW_SET(id, id_new);
|
||||
|
|
|
@ -189,9 +189,9 @@ void BKE_lib_override_library_free(struct IDOverrideLibrary **override, const bo
|
|||
|
||||
static ID *lib_override_library_create_from(Main *bmain, ID *reference_id)
|
||||
{
|
||||
ID *local_id;
|
||||
ID *local_id = BKE_id_copy(bmain, reference_id);
|
||||
|
||||
if (!BKE_id_copy(bmain, reference_id, (ID **)&local_id)) {
|
||||
if (local_id == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
id_us_min(local_id);
|
||||
|
@ -1699,8 +1699,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
|
|||
* Not impossible to do, but would rather see first if extra useless usual user handling
|
||||
* is actually a (performances) issue here. */
|
||||
|
||||
ID *tmp_id;
|
||||
BKE_id_copy(bmain, local->override_library->reference, &tmp_id);
|
||||
ID *tmp_id = BKE_id_copy(bmain, local->override_library->reference);
|
||||
|
||||
if (tmp_id == NULL) {
|
||||
return;
|
||||
|
@ -1868,7 +1867,7 @@ ID *BKE_lib_override_library_operations_store_start(Main *bmain,
|
|||
* (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. */
|
||||
BKE_id_copy((Main *)override_storage, local, &storage_id);
|
||||
storage_id = BKE_id_copy((Main *)override_storage, local);
|
||||
|
||||
if (storage_id != NULL) {
|
||||
PointerRNA rnaptr_reference, rnaptr_final, rnaptr_storage;
|
||||
|
|
|
@ -222,9 +222,7 @@ Light *BKE_light_add(Main *bmain, const char *name)
|
|||
|
||||
Light *BKE_light_copy(Main *bmain, const Light *la)
|
||||
{
|
||||
Light *la_copy;
|
||||
BKE_id_copy(bmain, &la->id, (ID **)&la_copy);
|
||||
return la_copy;
|
||||
return (Light *)BKE_id_copy(bmain, &la->id);
|
||||
}
|
||||
|
||||
void BKE_light_eval(struct Depsgraph *depsgraph, Light *la)
|
||||
|
|
|
@ -144,7 +144,5 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
|
|||
|
||||
LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
|
||||
{
|
||||
LightProbe *probe_copy;
|
||||
BKE_id_copy(bmain, &probe->id, (ID **)&probe_copy);
|
||||
return probe_copy;
|
||||
return (LightProbe *)BKE_id_copy(bmain, &probe->id);
|
||||
}
|
||||
|
|
|
@ -812,9 +812,7 @@ FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name)
|
|||
|
||||
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle)
|
||||
{
|
||||
FreestyleLineStyle *linestyle_copy;
|
||||
BKE_id_copy(bmain, &linestyle->id, (ID **)&linestyle_copy);
|
||||
return linestyle_copy;
|
||||
return (FreestyleLineStyle *)BKE_id_copy(bmain, &linestyle->id);
|
||||
}
|
||||
|
||||
FreestyleLineStyle *BKE_linestyle_active_from_view_layer(ViewLayer *view_layer)
|
||||
|
|
|
@ -1076,9 +1076,7 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
|
|||
|
||||
Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
|
||||
{
|
||||
Mask *mask_copy;
|
||||
BKE_id_copy(bmain, &mask->id, (ID **)&mask_copy);
|
||||
return mask_copy;
|
||||
return (Mask *)BKE_id_copy(bmain, &mask->id);
|
||||
}
|
||||
|
||||
void BKE_mask_point_free(MaskSplinePoint *point)
|
||||
|
|
|
@ -319,9 +319,7 @@ Material *BKE_gpencil_material_add(Main *bmain, const char *name)
|
|||
|
||||
Material *BKE_material_copy(Main *bmain, const Material *ma)
|
||||
{
|
||||
Material *ma_copy;
|
||||
BKE_id_copy(bmain, &ma->id, (ID **)&ma_copy);
|
||||
return ma_copy;
|
||||
return (Material *)BKE_id_copy(bmain, &ma->id);
|
||||
}
|
||||
|
||||
Material ***BKE_object_material_array_p(Object *ob)
|
||||
|
|
|
@ -219,9 +219,7 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
|
|||
|
||||
MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
|
||||
{
|
||||
MetaBall *mb_copy;
|
||||
BKE_id_copy(bmain, &mb->id, (ID **)&mb_copy);
|
||||
return mb_copy;
|
||||
return (MetaBall *)BKE_id_copy(bmain, &mb->id);
|
||||
}
|
||||
|
||||
/* most simple meta-element adding function
|
||||
|
|
|
@ -1019,9 +1019,7 @@ Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
|
|||
|
||||
Mesh *BKE_mesh_copy(Main *bmain, const Mesh *me)
|
||||
{
|
||||
Mesh *me_copy;
|
||||
BKE_id_copy(bmain, &me->id, (ID **)&me_copy);
|
||||
return me_copy;
|
||||
return (Mesh *)BKE_id_copy(bmain, &me->id);
|
||||
}
|
||||
|
||||
BMesh *BKE_mesh_to_bmesh_ex(const Mesh *me,
|
||||
|
|
|
@ -1920,9 +1920,7 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip,
|
|||
|
||||
MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
|
||||
{
|
||||
MovieClip *clip_copy;
|
||||
BKE_id_copy(bmain, &clip->id, (ID **)&clip_copy);
|
||||
return clip_copy;
|
||||
return (MovieClip *)BKE_id_copy(bmain, &clip->id);
|
||||
}
|
||||
|
||||
float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr)
|
||||
|
|
|
@ -1790,8 +1790,7 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
|
|||
*/
|
||||
Object *BKE_object_copy(Main *bmain, const Object *ob)
|
||||
{
|
||||
Object *ob_copy;
|
||||
BKE_id_copy(bmain, &ob->id, (ID **)&ob_copy);
|
||||
Object *ob_copy = (Object *)BKE_id_copy(bmain, &ob->id);
|
||||
|
||||
/* We increase object user count when linking to Collections. */
|
||||
id_us_min(&ob_copy->id);
|
||||
|
@ -1829,8 +1828,7 @@ Object *BKE_object_duplicate(Main *bmain,
|
|||
|
||||
Material ***matarar;
|
||||
|
||||
Object *obn;
|
||||
BKE_id_copy(bmain, &ob->id, (ID **)&obn);
|
||||
Object *obn = (Object *)BKE_id_copy(bmain, &ob->id);
|
||||
id_us_min(&obn->id);
|
||||
if (is_subprocess) {
|
||||
ID_NEW_SET(ob, obn);
|
||||
|
|
|
@ -679,9 +679,7 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
|
|||
|
||||
PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
|
||||
{
|
||||
PaintCurve *pc_copy;
|
||||
BKE_id_copy(bmain, &pc->id, (ID **)&pc_copy);
|
||||
return pc_copy;
|
||||
return (PaintCurve *)BKE_id_copy(bmain, &pc->id);
|
||||
}
|
||||
|
||||
Palette *BKE_paint_palette(Paint *p)
|
||||
|
@ -743,9 +741,7 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
|
|||
|
||||
Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
|
||||
{
|
||||
Palette *palette_copy;
|
||||
BKE_id_copy(bmain, &palette->id, (ID **)&palette_copy);
|
||||
return palette_copy;
|
||||
return (Palette *)BKE_id_copy(bmain, &palette->id);
|
||||
}
|
||||
|
||||
PaletteColor *BKE_palette_color_add(Palette *palette)
|
||||
|
|
|
@ -3909,9 +3909,7 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
|
|||
|
||||
ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings *part)
|
||||
{
|
||||
ParticleSettings *part_copy;
|
||||
BKE_id_copy(bmain, &part->id, (ID **)&part_copy);
|
||||
return part_copy;
|
||||
return (ParticleSettings *)BKE_id_copy(bmain, &part->id);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
|
|
|
@ -232,9 +232,7 @@ void *BKE_pointcloud_add_default(Main *bmain, const char *name)
|
|||
|
||||
PointCloud *BKE_pointcloud_copy(Main *bmain, const PointCloud *pointcloud)
|
||||
{
|
||||
PointCloud *pointcloud_copy;
|
||||
BKE_id_copy(bmain, &pointcloud->id, (ID **)&pointcloud_copy);
|
||||
return pointcloud_copy;
|
||||
return (PointCloud *)BKE_id_copy(bmain, &pointcloud->id);
|
||||
}
|
||||
|
||||
BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
|
||||
|
|
|
@ -873,7 +873,7 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
|
|||
|
||||
eDupli_ID_Flags duplicate_flags = U.dupflag | USER_DUP_OBJECT;
|
||||
|
||||
BKE_id_copy(bmain, (ID *)sce, (ID **)&sce_copy);
|
||||
sce_copy = (Scene *)BKE_id_copy(bmain, (ID *)sce);
|
||||
id_us_min(&sce_copy->id);
|
||||
id_us_ensure_real(&sce_copy->id);
|
||||
|
||||
|
|
|
@ -127,7 +127,5 @@ void *BKE_speaker_add(Main *bmain, const char *name)
|
|||
|
||||
Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
|
||||
{
|
||||
Speaker *spk_copy;
|
||||
BKE_id_copy(bmain, &spk->id, (ID **)&spk_copy);
|
||||
return spk_copy;
|
||||
return (Speaker *)BKE_id_copy(bmain, &spk->id);
|
||||
}
|
||||
|
|
|
@ -518,9 +518,7 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath)
|
|||
|
||||
Text *BKE_text_copy(Main *bmain, const Text *ta)
|
||||
{
|
||||
Text *ta_copy;
|
||||
BKE_id_copy(bmain, &ta->id, (ID **)&ta_copy);
|
||||
return ta_copy;
|
||||
return (Text *)BKE_id_copy(bmain, &ta->id);
|
||||
}
|
||||
|
||||
void BKE_text_clear(Text *text) /* called directly from rna */
|
||||
|
|
|
@ -457,9 +457,7 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
|
|||
|
||||
Tex *BKE_texture_copy(Main *bmain, const Tex *tex)
|
||||
{
|
||||
Tex *tex_copy;
|
||||
BKE_id_copy(bmain, &tex->id, (ID **)&tex_copy);
|
||||
return tex_copy;
|
||||
return (Tex *)BKE_id_copy(bmain, &tex->id);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
|
@ -612,9 +612,7 @@ void *BKE_volume_add(Main *bmain, const char *name)
|
|||
|
||||
Volume *BKE_volume_copy(Main *bmain, const Volume *volume)
|
||||
{
|
||||
Volume *volume_copy;
|
||||
BKE_id_copy(bmain, &volume->id, (ID **)&volume_copy);
|
||||
return volume_copy;
|
||||
return (Volume *)BKE_id_copy(bmain, &volume->id);
|
||||
}
|
||||
|
||||
/* Sequence */
|
||||
|
|
|
@ -1819,8 +1819,7 @@ static Collection *single_object_users_collection(Main *bmain,
|
|||
/* Generate new copies for objects in given collection and all its children,
|
||||
* and optionally also copy collections themselves. */
|
||||
if (copy_collections && !is_master_collection) {
|
||||
Collection *collection_new;
|
||||
BKE_id_copy(bmain, &collection->id, (ID **)&collection_new);
|
||||
Collection *collection_new = (Collection *)BKE_id_copy(bmain, &collection->id);
|
||||
id_us_min(&collection_new->id);
|
||||
collection = ID_NEW_SET(collection, collection_new);
|
||||
}
|
||||
|
|
|
@ -523,16 +523,12 @@ static ID *rna_ID_evaluated_get(ID *id, struct Depsgraph *depsgraph)
|
|||
|
||||
static ID *rna_ID_copy(ID *id, Main *bmain)
|
||||
{
|
||||
ID *newid;
|
||||
ID *newid = BKE_id_copy(bmain, id);
|
||||
|
||||
if (BKE_id_copy(bmain, id, &newid)) {
|
||||
if (newid != NULL) {
|
||||
id_us_min(newid);
|
||||
}
|
||||
return newid;
|
||||
if (newid != NULL) {
|
||||
id_us_min(newid);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return newid;
|
||||
}
|
||||
|
||||
static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
|
||||
|
|
Loading…
Reference in New Issue