Cleanup/Refactor: pass Main pointer to all ID copy functions.
authorBastien Montagne <montagne29@wanadoo.fr>
Sun, 10 Jul 2016 12:52:00 +0000 (14:52 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Sun, 10 Jul 2016 12:52:00 +0000 (14:52 +0200)
Also allows us to get rid of a few _copy_ex() versions...

67 files changed:
source/blender/blenkernel/BKE_action.h
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/BKE_camera.h
source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/BKE_gpencil.h
source/blender/blenkernel/BKE_group.h
source/blender/blenkernel/BKE_key.h
source/blender/blenkernel/BKE_lamp.h
source/blender/blenkernel/BKE_lattice.h
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/BKE_mask.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_mball.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_speaker.h
source/blender/blenkernel/BKE_texture.h
source/blender/blenkernel/BKE_world.h
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/gpencil.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/linestyle.c
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/collada/DocumentImporter.cpp
source/blender/editors/curve/editcurve.c
source/blender/editors/gpencil/gpencil_undo.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/physics/particle_object.c
source/blender/editors/render/render_shading.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/space_action/action_data.c
source/blender/editors/space_nla/nla_edit.c
source/blender/editors/space_node/node_group.c
source/blender/makesrna/intern/rna_ID.c
source/gameengine/Converter/BL_ArmatureObject.cpp
source/gameengine/Converter/BL_ShapeDeformer.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Ketsji/BL_Action.cpp

index cb282b46bec53b5dd9bdfe1e633827956dd1ae31..07fa6ac71f6fd6da0f8e812a939744fcbd2ec597 100644 (file)
@@ -58,7 +58,7 @@ extern "C" {
 struct bAction *add_empty_action(struct Main *bmain, const char name[]);
 
 /* Allocate a copy of the given Action and all its data */     
-struct bAction *BKE_action_copy(struct bAction *src);
+struct bAction *BKE_action_copy(struct Main *bmain, struct bAction *src);
 
 /* Deallocate all of the Action's data, but not the Action itself */
 void BKE_action_free(struct bAction *act);
index cc082c084cec47aa5dfc2b3e04a2a0e74bc954b7..8004724ddf31ba58adf6af572d4ec4101fb4e574 100644 (file)
@@ -77,7 +77,7 @@ 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 bArmature *arm);
-struct bArmature *BKE_armature_copy(struct bArmature *arm);
+struct bArmature *BKE_armature_copy(struct Main *bmain, struct bArmature *arm);
 
 /* Bounding box. */
 struct BoundBox *BKE_armature_boundbox_get(struct Object *ob);
index c663458963c957a900d872ffdf871cfec4a0780d..309785783ecccee73102f8d6bea48308d85a6f6c 100644 (file)
@@ -44,7 +44,7 @@ void BKE_brush_system_exit(void);
 void BKE_brush_init(struct Brush *brush);
 struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short ob_mode);
 struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
-struct Brush *BKE_brush_copy(struct Brush *brush);
+struct Brush *BKE_brush_copy(struct Main *bmain, struct Brush *brush);
 void BKE_brush_make_local(struct Brush *brush);
 void BKE_brush_unlink(struct Main *bmain, struct Brush *brush);
 void BKE_brush_free(struct Brush *brush);
index d13a711c589160fba2654941c4a22ca43302e5cf..f78df88c77aa22132ed69e44b95edf3cfbe09b9b 100644 (file)
@@ -52,7 +52,7 @@ struct GPUFXSettings;
 
 void BKE_camera_init(struct Camera *cam);
 void *BKE_camera_add(struct Main *bmain, const char *name);
-struct Camera *BKE_camera_copy(struct Camera *cam);
+struct Camera *BKE_camera_copy(struct Main *bmain, struct Camera *cam);
 void BKE_camera_make_local(struct Camera *cam);
 void BKE_camera_free(struct Camera *ca);
 
index ef3d14ce16b9f6f40cf7c93cc2dde56c171c8d18..89dbe2469105bf296c7028e61585bef7d92e0b89 100644 (file)
@@ -70,8 +70,7 @@ void BKE_curve_free(struct Curve *cu);
 void BKE_curve_editfont_free(struct Curve *cu);
 void BKE_curve_init(struct Curve *cu);
 struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
-struct Curve *BKE_curve_copy(struct Curve *cu);
-struct Curve *BKE_curve_copy_ex(struct Main *bmain, struct Curve *cu);
+struct Curve *BKE_curve_copy(struct Main *bmain, struct Curve *cu);
 void BKE_curve_make_local(struct Main *bmain, struct Curve *cu);
 short BKE_curve_type_get(struct Curve *cu);
 void BKE_curve_type_test(struct Object *ob);
index 24e330d927f82facdbd58cb2c0fdcd4f9e4b5cea..6159531d8bd392b98c96a2974ab545a570e470af 100644 (file)
@@ -36,6 +36,7 @@ struct bGPdata;
 struct bGPDlayer;
 struct bGPDframe;
 struct bGPDstroke;
+struct Main;
 
 /* ------------ Grease-Pencil API ------------------ */
 
@@ -53,7 +54,7 @@ struct bGPdata *gpencil_data_addnew(const char name[]);
 
 struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
 struct bGPDlayer *gpencil_layer_duplicate(struct bGPDlayer *src);
-struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd, bool internal_copy);
+struct bGPdata *gpencil_data_duplicate(struct Main *bmain, struct bGPdata *gpd, bool internal_copy);
 
 void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);
 
index ae6e52b613b247777e1461404398b0c2863965cf..4f2c89070cbb4922773a1024f05e5f2a5cae263a 100644 (file)
@@ -42,7 +42,7 @@ struct Scene;
 
 void          BKE_group_free(struct Group *group);
 struct Group *BKE_group_add(struct Main *bmain, const char *name);
-struct Group *BKE_group_copy(struct Group *group);
+struct Group *BKE_group_copy(struct Main *bmain, struct Group *group);
 bool          BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
 bool          BKE_group_object_unlink(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
 struct Group *BKE_group_object_find(struct Group *group, struct Object *ob);
index 86484db3809d1578e8895030f539701c49889db6..f30f9eac4e81b115ba82cef62028a573111cb0d2 100644 (file)
@@ -51,8 +51,7 @@ extern "C" {
 void        BKE_key_free(struct Key *sc);
 void        BKE_key_free_nolib(struct Key *key);
 struct Key *BKE_key_add(struct ID *id);
-struct Key *BKE_key_copy(struct Key *key);
-struct Key *BKE_key_copy_ex(struct Main *bmain, struct Key *key);
+struct Key *BKE_key_copy(struct Main *bmain, struct Key *key);
 struct Key *BKE_key_copy_nolib(struct Key *key);
 void        BKE_key_make_local(struct Main *bmain, struct Key *key);
 void        BKE_key_sort(struct Key *key);
index d830c19651fd5e8dc100b512a0db68a07b2fb84b..3bdef8eca484bf96ef0b62598474cfbbbde249d8 100644 (file)
@@ -44,7 +44,7 @@ struct Scene;
 
 void BKE_lamp_init(struct Lamp *la);
 struct Lamp *BKE_lamp_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
-struct Lamp *BKE_lamp_copy(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
+struct Lamp *BKE_lamp_copy(struct Main *bmain, struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
 struct Lamp *localize_lamp(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
 void BKE_lamp_make_local(struct Lamp *la);
 void BKE_lamp_free(struct Lamp *la);
index a82525225d5564108a7fa89e722357fd9e28aa32..606df9dcec88eef2c36711fb4096f503f22bfe32 100644 (file)
@@ -47,8 +47,7 @@ struct MDeformVert;
 void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
 void BKE_lattice_init(struct Lattice *lt);
 struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
-struct Lattice *BKE_lattice_copy(struct Lattice *lt);
-struct Lattice *BKE_lattice_copy_ex(struct Main *bmain, struct Lattice *lt);
+struct Lattice *BKE_lattice_copy(struct Main *bmain, struct Lattice *lt);
 void BKE_lattice_free(struct Lattice *lt);
 void BKE_lattice_make_local(struct Main *bmain, struct Lattice *lt);
 void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
index 37937aa20b367cb025069946f970cf189c18a10f..f3a02019064d13b76ed4afafeb66c9d4e902dd2e 100644 (file)
@@ -52,9 +52,8 @@ struct PropertyRNA;
 void *BKE_libblock_alloc_notest(short type);
 void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void  BKE_libblock_init_empty(struct ID *id);
-void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void *BKE_libblock_copy(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
-void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void  BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
 void  BKE_libblock_relink(struct ID *id);
 void  BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
@@ -83,7 +82,7 @@ void id_fake_user_clear(struct ID *id);
 
 bool id_make_local(struct Main *bmain, struct ID *id, bool test);
 bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
-bool id_copy(struct ID *id, struct ID **newid, bool test);
+bool id_copy(struct Main *bmain, struct ID *id, struct ID **newid, bool test);
 void id_sort_by_name(struct ListBase *lb, struct ID *id);
 
 bool new_id(struct ListBase *lb, struct ID *id, const char *name);
index f3d12b5a8cc51948fca24d295edca4e1b557aa9a..97bfd0f3f078ac2f0ff118023b9da379f04f2c31 100644 (file)
@@ -123,7 +123,7 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const eMask
 /* general */
 struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
 struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
-struct Mask *BKE_mask_copy(struct Mask *mask);
+struct Mask *BKE_mask_copy(struct Main *bmain, struct Mask *mask);
 
 void BKE_mask_free(struct Mask *mask);
 
index 539cf8a57d7e3bf3b9448b861c08cdd023455ed9..bcb2db759df5164ba32728b233810fa3130cdac6 100644 (file)
@@ -54,7 +54,7 @@ void BKE_material_init(struct Material *ma);
 void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
 void BKE_material_remap_object_calc(struct  Object *ob_dst, struct Object *ob_src, short *remap_src_to_dst);
 struct Material *BKE_material_add(struct Main *bmain, const char *name);
-struct Material *BKE_material_copy(struct Material *ma);
+struct Material *BKE_material_copy(struct Main *bmain, struct Material *ma);
 struct Material *localize_material(struct Material *ma);
 struct Material *give_node_material(struct Material *ma); /* returns node material or self */
 void BKE_material_make_local(struct Material *ma);
index abb1259ca5489e4133287f3787390cbe2f496cac..42704c1b2db73a95e149d9a5ec418463e05fe282 100644 (file)
@@ -41,8 +41,7 @@ struct MetaElem;
 void BKE_mball_free(struct MetaBall *mb);
 void BKE_mball_init(struct MetaBall *mb);
 struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
-struct MetaBall *BKE_mball_copy(struct MetaBall *mb);
-struct MetaBall *BKE_mball_copy_ex(struct Main *bmain, struct MetaBall *mb);
+struct MetaBall *BKE_mball_copy(struct Main *bmain, struct MetaBall *mb);
 
 void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb);
 
index 3d05af9a1265c414d760600e140db4b79d06c6f0..d3bb34d7a41c7521f3425b2d884a32831f1f0cd6 100644 (file)
@@ -87,8 +87,7 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
 void BKE_mesh_free(struct Mesh *me);
 void BKE_mesh_init(struct Mesh *me);
 struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
-struct Mesh *BKE_mesh_copy_ex(struct Main *bmain, struct Mesh *me);
-struct Mesh *BKE_mesh_copy(struct Mesh *me);
+struct Mesh *BKE_mesh_copy(struct Main *bmain, struct Mesh *me);
 void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
 void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
 
index bf198c9b86b50608f9d189c3c51b5c2ebf275400..c5d10441ebecb77ce9ae98c00757b89aed22f882 100644 (file)
@@ -336,7 +336,7 @@ struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char
 /* copy/free funcs, need to manage ID users */
 void              ntreeFreeTree(struct bNodeTree *ntree);
 struct bNodeTree *ntreeCopyTree_ex(struct bNodeTree *ntree, struct Main *bmain, const bool do_id_user);
-struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
+struct bNodeTree *ntreeCopyTree(struct Main *bmain, struct bNodeTree *ntree);
 void              ntreeSwitchID_ex(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to, const bool do_id_user);
 void              ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
 /* node->id user count */
index a1f1bee2642ed1117819a33b0255c5f7f29851b0..1f0dc5f181414852235da2a06cf885b6b5365f9d 100644 (file)
@@ -106,7 +106,7 @@ struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct Scene *scene)
 struct Object *BKE_object_lod_matob_get(struct Object *ob, struct Scene *scene);
 
 struct Object *BKE_object_copy_ex(struct Main *bmain, struct Object *ob, bool copy_caches);
-struct Object *BKE_object_copy(struct Object *ob);
+struct Object *BKE_object_copy(struct Main *bmain, struct Object *ob);
 void BKE_object_make_local(struct Main *bmain, struct Object *ob);
 bool BKE_object_is_libdata(struct Object *ob);
 bool BKE_object_obdata_is_libdata(struct Object *ob);
index 5daa94c430292ee2a0bd08befd791556e0fedaaa..4f43037682a3213ebaa93c831f940b182af394d9 100644 (file)
@@ -323,7 +323,7 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
 struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name);
 void object_remove_particle_system(struct Scene *scene, struct Object *ob);
 struct ParticleSettings *psys_new_settings(const char *name, struct Main *main);
-struct ParticleSettings *BKE_particlesettings_copy(struct ParticleSettings *part);
+struct ParticleSettings *BKE_particlesettings_copy(struct Main *bmain, struct ParticleSettings *part);
 void BKE_particlesettings_make_local(struct ParticleSettings *part);
 
 void psys_reset(struct ParticleSystem *psys, int mode);
index ccb7dc8e015549b21d948f086d7104819e6b7a76..03af0b7d6c930783f8a2df3dc3c43a08c0e6a6f9 100644 (file)
@@ -98,7 +98,7 @@ void BKE_scene_base_flag_from_objects(struct Scene *scene);
 void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
 struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
 
-struct Scene *BKE_scene_copy(struct Scene *sce, int type);
+struct Scene *BKE_scene_copy(struct Main *bmain, struct Scene *sce, int type);
 void BKE_scene_groups_relink(struct Scene *sce);
 
 struct Object *BKE_scene_camera_find(struct Scene *sc);
index 5f30df1d6e31a8f514c3122658a6191e2bd0d308..1f633e9854b23315dd3f75f8ed7bf575d333744b 100644 (file)
@@ -33,7 +33,7 @@ struct Speaker;
 
 void BKE_speaker_init(struct Speaker *spk);
 void *BKE_speaker_add(struct Main *bmain, const char *name);
-struct Speaker *BKE_speaker_copy(struct Speaker *spk);
+struct Speaker *BKE_speaker_copy(struct Main *bmain, struct Speaker *spk);
 void BKE_speaker_make_local(struct Speaker *spk);
 void BKE_speaker_free(struct Speaker *spk);
 
index 95918b9ca0be6dc29ead1b773d195a8b88cff00f..37bd25cf067427bdf8e4703a37faa236968a830c 100644 (file)
@@ -69,7 +69,7 @@ void colorband_update_sort(struct ColorBand *coba);
 
 void         BKE_texture_free(struct Tex *tex);
 void         BKE_texture_default(struct Tex *tex);
-struct Tex  *BKE_texture_copy(struct Tex *tex);
+struct Tex  *BKE_texture_copy(struct Main *bmain, 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 Tex *tex);
index 0be61fe022983670b8a824084b6f8a7c3bad6655..197cebc423e486f200c3c1cecea63edec59bfa70 100644 (file)
@@ -39,7 +39,7 @@ struct World;
 void BKE_world_free(struct World *sc);
 void BKE_world_init(struct World *wrld);
 struct World *add_world(struct Main *bmian, const char *name);
-struct World *BKE_world_copy(struct World *wrld);
+struct World *BKE_world_copy(struct Main *bmain, struct World *wrld);
 struct World *localize_world(struct World *wrld);
 void BKE_world_make_local(struct World *wrld);
 
index 9d6b2a0568189b0fcadf13049cd57b48cf6db99f..5ac80ae1b7c5312e0d63c3a982b7f374ca6bf44d 100644 (file)
@@ -148,7 +148,7 @@ void BKE_action_make_local(bAction *act)
                id_clear_lib_data(bmain, &act->id);
        }
        else if (mlac.is_local && mlac.is_lib) {
-               mlac.act_new = BKE_action_copy(act);
+               mlac.act_new = BKE_action_copy(bmain, act);
                mlac.act_new->id.us = 0;
 
                BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id);
@@ -176,7 +176,7 @@ void BKE_action_free(bAction *act)
 
 /* .................................. */
 
-bAction *BKE_action_copy(bAction *src)
+bAction *BKE_action_copy(Main *bmain, bAction *src)
 {
        bAction *dst = NULL;
        bActionGroup *dgrp, *sgrp;
@@ -184,7 +184,7 @@ bAction *BKE_action_copy(bAction *src)
        
        if (src == NULL) 
                return NULL;
-       dst = BKE_libblock_copy(&src->id);
+       dst = BKE_libblock_copy(bmain, &src->id);
        
        /* duplicate the lists of groups and markers */
        BLI_duplicatelist(&dst->groups, &src->groups);
@@ -214,7 +214,7 @@ bAction *BKE_action_copy(bAction *src)
        }
        
        if (ID_IS_LINKED_DATABLOCK(src)) {
-               BKE_id_lib_local_paths(G.main, src->id.lib, &dst->id);
+               BKE_id_lib_local_paths(bmain, src->id.lib, &dst->id);
        }
 
        return dst;
index 10e7b01950537dd221cab51b4889ad7f49cc71c9..f478a19235cbde4e5a4bb40ed24faa9301c26db2 100644 (file)
@@ -268,8 +268,8 @@ AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action)
        
        /* make a copy of action - at worst, user has to delete copies... */
        if (do_action) {
-               dadt->action = BKE_action_copy(adt->action);
-               dadt->tmpact = BKE_action_copy(adt->tmpact);
+               dadt->action = BKE_action_copy(G.main, adt->action);
+               dadt->tmpact = BKE_action_copy(G.main, adt->tmpact);
        }
        else {
                id_us_plus((ID *)dadt->action);
@@ -313,11 +313,11 @@ void BKE_animdata_copy_id_action(ID *id)
        if (adt) {
                if (adt->action) {
                        id_us_min((ID *)adt->action);
-                       adt->action = BKE_action_copy(adt->action);
+                       adt->action = BKE_action_copy(G.main, adt->action);
                }
                if (adt->tmpact) {
                        id_us_min((ID *)adt->tmpact);
-                       adt->tmpact = BKE_action_copy(adt->tmpact);
+                       adt->tmpact = BKE_action_copy(G.main, adt->tmpact);
                }
        }
 }
@@ -341,8 +341,8 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes a
        /* handle actions... */
        if (action_mode == ADT_MERGECOPY_SRC_COPY) {
                /* make a copy of the actions */
-               dst->action = BKE_action_copy(src->action);
-               dst->tmpact = BKE_action_copy(src->tmpact);
+               dst->action = BKE_action_copy(G.main, src->action);
+               dst->tmpact = BKE_action_copy(G.main, src->tmpact);
        }
        else if (action_mode == ADT_MERGECOPY_SRC_REF) {
                /* make a reference to it */
index 572490f937c8b83e616ea47cc53c1ae51ca0ff1b..4ed0196ba9d44550382488db79a96b88bb2ab0f7 100644 (file)
@@ -168,7 +168,7 @@ void BKE_armature_make_local(bArmature *arm)
                id_clear_lib_data(bmain, &arm->id);
        }
        else if (is_local && is_lib) {
-               bArmature *arm_new = BKE_armature_copy(arm);
+               bArmature *arm_new = BKE_armature_copy(bmain, arm);
                arm_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
@@ -208,13 +208,13 @@ static void copy_bonechildren(Bone *newBone, Bone *oldBone, Bone *actBone, Bone
        }
 }
 
-bArmature *BKE_armature_copy(bArmature *arm)
+bArmature *BKE_armature_copy(Main *bmain, bArmature *arm)
 {
        bArmature *newArm;
        Bone *oldBone, *newBone;
        Bone *newActBone = NULL;
 
-       newArm = BKE_libblock_copy(&arm->id);
+       newArm = BKE_libblock_copy(bmain, &arm->id);
        BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
 
        /* Duplicate the childrens' lists */
@@ -232,7 +232,7 @@ bArmature *BKE_armature_copy(bArmature *arm)
        newArm->sketch = NULL;
 
        if (ID_IS_LINKED_DATABLOCK(arm)) {
-               BKE_id_lib_local_paths(G.main, arm->id.lib, &newArm->id);
+               BKE_id_lib_local_paths(bmain, arm->id.lib, &newArm->id);
        }
 
        return newArm;
index 6d8dbcc688cef2cf46320f778ec84ab7344ce9b8..5505d3861d764afcdcfad226ea174a7521d114d3 100644 (file)
@@ -170,11 +170,11 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode)
        return NULL;
 }
 
-Brush *BKE_brush_copy(Brush *brush)
+Brush *BKE_brush_copy(Main *bmain, Brush *brush)
 {
        Brush *brushn;
        
-       brushn = BKE_libblock_copy(&brush->id);
+       brushn = BKE_libblock_copy(bmain, &brush->id);
 
        if (brush->mtex.tex)
                id_us_plus((ID *)brush->mtex.tex);
@@ -196,7 +196,7 @@ Brush *BKE_brush_copy(Brush *brush)
        id_fake_user_set(&brush->id);
 
        if (ID_IS_LINKED_DATABLOCK(brush)) {
-               BKE_id_lib_local_paths(G.main, brush->id.lib, &brushn->id);
+               BKE_id_lib_local_paths(bmain, brush->id.lib, &brushn->id);
        }
 
        return brushn;
@@ -261,7 +261,7 @@ void BKE_brush_make_local(Brush *brush)
                id_fake_user_set(&brush->id);
        }
        else if (is_local && is_lib) {
-               Brush *brush_new = BKE_brush_copy(brush);  /* Ensures FAKE_USER is set */
+               Brush *brush_new = BKE_brush_copy(bmain, brush);  /* Ensures FAKE_USER is set */
                id_us_min(&brush_new->id);  /* Remove user added by standard BKE_libblock_copy(). */
 
                /* Remap paths of new ID using old library as base. */
@@ -469,6 +469,7 @@ void BKE_brush_curve_preset(Brush *b, int preset)
        curvemapping_changed(b->curve, false);
 }
 
+/* XXX Unused function. */
 int BKE_brush_texture_set_nr(Brush *brush, int nr)
 {
        ID *idtest, *id = NULL;
@@ -477,7 +478,7 @@ int BKE_brush_texture_set_nr(Brush *brush, int nr)
 
        idtest = (ID *)BLI_findlink(&G.main->tex, nr - 1);
        if (idtest == NULL) { /* new tex */
-               if (id) idtest = (ID *)BKE_texture_copy((Tex *)id);
+               if (id) idtest = (ID *)BKE_texture_copy(G.main, (Tex *)id);
                else idtest = (ID *)BKE_texture_add(G.main, "Tex");
                id_us_min(idtest);
        }
index 9fd2c2ddd1409460e0a89c386e88f0e0165a4ed1..41c67ef5365b68bf087db5af1f9b972dda7402fd 100644 (file)
@@ -91,16 +91,16 @@ void *BKE_camera_add(Main *bmain, const char *name)
        return cam;
 }
 
-Camera *BKE_camera_copy(Camera *cam)
+Camera *BKE_camera_copy(Main *bmain, Camera *cam)
 {
        Camera *camn;
        
-       camn = BKE_libblock_copy(&cam->id);
+       camn = BKE_libblock_copy(bmain, &cam->id);
 
        id_lib_extern((ID *)camn->dof_ob);
 
        if (ID_IS_LINKED_DATABLOCK(cam)) {
-               BKE_id_lib_local_paths(G.main, cam->id.lib, &camn->id);
+               BKE_id_lib_local_paths(bmain, cam->id.lib, &camn->id);
        }
 
        return camn;
@@ -134,7 +134,7 @@ void BKE_camera_make_local(Camera *cam)
                id_clear_lib_data(bmain, &cam->id);
        }
        else if (is_local && is_lib) {
-               Camera *cam_new = BKE_camera_copy(cam);
+               Camera *cam_new = BKE_camera_copy(bmain, cam);
 
                cam_new->id.us = 0;
 
index 4dc0f1ccf8c0f35baca25abed4f78aae07d10e3b..3a7be9487605ae58bfeec9564961b0497dbdf415 100644 (file)
@@ -174,12 +174,12 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
        return cu;
 }
 
-Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
+Curve *BKE_curve_copy(Main *bmain, Curve *cu)
 {
        Curve *cun;
        int a;
 
-       cun = BKE_libblock_copy_ex(bmain, &cu->id);
+       cun = BKE_libblock_copy(bmain, &cu->id);
 
        BLI_listbase_clear(&cun->nurb);
        BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb));
@@ -195,7 +195,7 @@ Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
        cun->bb = MEM_dupallocN(cu->bb);
 
        if (cu->key) {
-               cun->key = BKE_key_copy_ex(bmain, cu->key);
+               cun->key = BKE_key_copy(bmain, cu->key);
                cun->key->from = (ID *)cun;
        }
 
@@ -219,11 +219,6 @@ Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
        return cun;
 }
 
-Curve *BKE_curve_copy(Curve *cu)
-{
-       return BKE_curve_copy_ex(G.main, cu);
-}
-
 static int extern_local_curve_callback(
         void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
 {
@@ -263,7 +258,7 @@ void BKE_curve_make_local(Main *bmain, Curve *cu)
                        extern_local_curve(cu);
                }
                else {
-                       Curve *cu_new = BKE_curve_copy_ex(bmain, cu);
+                       Curve *cu_new = BKE_curve_copy(bmain, cu);
 
                        cu_new->id.us = 0;
 
index af1bcd0c5457e60d1495c4c23e22b85d5345505b..ac4f566dc6283815da72be080d54f19afa482e5b 100644 (file)
@@ -49,6 +49,7 @@
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 #include "BKE_library.h"
+#include "BKE_main.h"
 
 
 /* ************************************************** */
@@ -358,7 +359,7 @@ bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src)
 }
 
 /* make a copy of a given gpencil datablock */
-bGPdata *gpencil_data_duplicate(bGPdata *src, bool internal_copy)
+bGPdata *gpencil_data_duplicate(Main *bmain, bGPdata *src, bool internal_copy)
 {
        bGPDlayer *gpl, *gpld;
        bGPdata *dst;
@@ -374,7 +375,7 @@ bGPdata *gpencil_data_duplicate(bGPdata *src, bool internal_copy)
        }
        else {
                /* make a copy when others use this */
-               dst = BKE_libblock_copy(&src->id);
+               dst = BKE_libblock_copy(bmain, &src->id);
        }
        
        /* copy layers */
index ce7ef1f710a46a195f51d0a39119951a6b1a4fb3..99a83665db7b17e6df5adba23e8a772d988acefa 100644 (file)
@@ -87,18 +87,18 @@ Group *BKE_group_add(Main *bmain, const char *name)
        return group;
 }
 
-Group *BKE_group_copy(Group *group)
+Group *BKE_group_copy(Main *bmain, Group *group)
 {
        Group *groupn;
 
-       groupn = BKE_libblock_copy(&group->id);
+       groupn = BKE_libblock_copy(bmain, &group->id);
        BLI_duplicatelist(&groupn->gobject, &group->gobject);
 
        /* Do not copy group's preview (same behavior as for objects). */
        groupn->preview = NULL;
 
        if (ID_IS_LINKED_DATABLOCK(group)) {
-               BKE_id_lib_local_paths(G.main, group->id.lib, &groupn->id);
+               BKE_id_lib_local_paths(bmain, group->id.lib, &groupn->id);
        }
 
        return groupn;
index ed8095444a486cde63f066b6865e08e7c2340ac2..2b7968eec1d7081679e4d58b79c137d2a2bc1aeb 100644 (file)
@@ -150,12 +150,12 @@ Key *BKE_key_add(ID *id)    /* common function */
        return key;
 }
 
-Key *BKE_key_copy_ex(Main *bmain, Key *key)
+Key *BKE_key_copy(Main *bmain, Key *key)
 {
        Key *keyn;
        KeyBlock *kbn, *kb;
        
-       keyn = BKE_libblock_copy_ex(bmain, &key->id);
+       keyn = BKE_libblock_copy(bmain, &key->id);
        
        BLI_duplicatelist(&keyn->block, &key->block);
        
@@ -177,11 +177,6 @@ Key *BKE_key_copy_ex(Main *bmain, Key *key)
        return keyn;
 }
 
-Key *BKE_key_copy(Key *key)
-{
-       return BKE_key_copy_ex(G.main, key);
-}
-
 Key *BKE_key_copy_nolib(Key *key)
 {
        Key *keyn;
index 433968346507d41a39b89808d88c4d2f87c534d1..7ab71938cf2a9ad919b08d0912cc989343d148ef 100644 (file)
@@ -114,12 +114,12 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
        return la;
 }
 
-Lamp *BKE_lamp_copy(Lamp *la)
+Lamp *BKE_lamp_copy(Main *bmain, Lamp *la)
 {
        Lamp *lan;
        int a;
        
-       lan = BKE_libblock_copy(&la->id);
+       lan = BKE_libblock_copy(bmain, &la->id);
 
        for (a = 0; a < MAX_MTEX; a++) {
                if (lan->mtex[a]) {
@@ -132,13 +132,13 @@ Lamp *BKE_lamp_copy(Lamp *la)
        lan->curfalloff = curvemapping_copy(la->curfalloff);
 
        if (la->nodetree)
-               lan->nodetree = ntreeCopyTree(la->nodetree);
+               lan->nodetree = ntreeCopyTree(bmain, la->nodetree);
        
        if (la->preview)
                lan->preview = BKE_previewimg_copy(la->preview);
        
        if (ID_IS_LINKED_DATABLOCK(la)) {
-               BKE_id_lib_local_paths(G.main, la->id.lib, &lan->id);
+               BKE_id_lib_local_paths(bmain, la->id.lib, &lan->id);
        }
 
        return lan;
@@ -200,7 +200,7 @@ void BKE_lamp_make_local(Lamp *la)
                id_clear_lib_data(bmain, &la->id);
        }
        else if (is_local && is_lib) {
-               Lamp *la_new = BKE_lamp_copy(la);
+               Lamp *la_new = BKE_lamp_copy(bmain, la);
                la_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
index e85fad555324de55cf419019e387ada0a4f354f6..88b0418938fa2ef38213e2018db06a86eea5bfe7 100644 (file)
@@ -277,15 +277,15 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
        return lt;
 }
 
-Lattice *BKE_lattice_copy_ex(Main *bmain, Lattice *lt)
+Lattice *BKE_lattice_copy(Main *bmain, Lattice *lt)
 {
        Lattice *ltn;
 
-       ltn = BKE_libblock_copy_ex(bmain, &lt->id);
+       ltn = BKE_libblock_copy(bmain, &lt->id);
        ltn->def = MEM_dupallocN(lt->def);
 
        if (lt->key) {
-               ltn->key = BKE_key_copy_ex(bmain, ltn->key);
+               ltn->key = BKE_key_copy(bmain, ltn->key);
                ltn->key->from = (ID *)ltn;
        }
        
@@ -304,11 +304,6 @@ Lattice *BKE_lattice_copy_ex(Main *bmain, Lattice *lt)
        return ltn;
 }
 
-Lattice *BKE_lattice_copy(Lattice *lt)
-{
-       return BKE_lattice_copy_ex(G.main, lt);
-}
-
 /** Free (or release) any data used by this lattice (does not free the lattice itself). */
 void BKE_lattice_free(Lattice *lt)
 {
@@ -358,7 +353,7 @@ void BKE_lattice_make_local(Main *bmain, Lattice *lt)
                        /* No extern_local_lattice... */
                }
                else {
-                       Lattice *lt_new = BKE_lattice_copy_ex(bmain, lt);
+                       Lattice *lt_new = BKE_lattice_copy(bmain, lt);
 
                        lt_new->id.us = 0;
 
index fa63e7a5f848e4090038e1293c77b1c35f2935d6..f85765435f2f84a5595cbde0981944b5f7f465e1 100644 (file)
@@ -344,9 +344,11 @@ bool id_make_local(Main *bmain, ID *id, bool test)
  * 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(ID *id, ID **newid, bool test)
+bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
 {
-       if (!test) *newid = NULL;
+       if (!test) {
+               *newid = NULL;
+       }
 
        /* conventions:
         * - make shallow copy, only this ID block
@@ -357,83 +359,83 @@ bool id_copy(ID *id, ID **newid, bool test)
                case ID_LI:
                        return false;  /* can't be copied from here */
                case ID_OB:
-                       if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
+                       if (!test) *newid = (ID *)BKE_object_copy(bmain, (Object *)id);
                        return true;
                case ID_ME:
-                       if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
+                       if (!test) *newid = (ID *)BKE_mesh_copy(bmain, (Mesh *)id);
                        return true;
                case ID_CU:
-                       if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
+                       if (!test) *newid = (ID *)BKE_curve_copy(bmain, (Curve *)id);
                        return true;
                case ID_MB:
-                       if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
+                       if (!test) *newid = (ID *)BKE_mball_copy(bmain, (MetaBall *)id);
                        return true;
                case ID_MA:
-                       if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
+                       if (!test) *newid = (ID *)BKE_material_copy(bmain, (Material *)id);
                        return true;
                case ID_TE:
-                       if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
+                       if (!test) *newid = (ID *)BKE_texture_copy(bmain, (Tex *)id);
                        return true;
                case ID_IM:
-                       if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id);
+                       if (!test) *newid = (ID *)BKE_image_copy(bmain, (Image *)id);
                        return true;
                case ID_LT:
-                       if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
+                       if (!test) *newid = (ID *)BKE_lattice_copy(bmain, (Lattice *)id);
                        return true;
                case ID_LA:
-                       if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
+                       if (!test) *newid = (ID *)BKE_lamp_copy(bmain, (Lamp *)id);
                        return true;
                case ID_SPK:
-                       if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
+                       if (!test) *newid = (ID *)BKE_speaker_copy(bmain, (Speaker *)id);
                        return true;
                case ID_CA:
-                       if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
+                       if (!test) *newid = (ID *)BKE_camera_copy(bmain, (Camera *)id);
                        return true;
                case ID_IP:
                        return false;  /* deprecated */
                case ID_KE:
-                       if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
+                       if (!test) *newid = (ID *)BKE_key_copy(bmain, (Key *)id);
                        return true;
                case ID_WO:
-                       if (!test) *newid = (ID *)BKE_world_copy((World *)id);
+                       if (!test) *newid = (ID *)BKE_world_copy(bmain, (World *)id);
                        return true;
                case ID_SCR:
                        return false;  /* can't be copied from here */
                case ID_VF:
                        return false;  /* not implemented */
                case ID_TXT:
-                       if (!test) *newid = (ID *)BKE_text_copy(G.main, (Text *)id);
+                       if (!test) *newid = (ID *)BKE_text_copy(bmain, (Text *)id);
                        return true;
                case ID_SO:
                        return false;  /* not implemented */
                case ID_GR:
-                       if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
+                       if (!test) *newid = (ID *)BKE_group_copy(bmain, (Group *)id);
                        return true;
                case ID_AR:
-                       if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
+                       if (!test) *newid = (ID *)BKE_armature_copy(bmain, (bArmature *)id);
                        return true;
                case ID_AC:
-                       if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
+                       if (!test) *newid = (ID *)BKE_action_copy(bmain, (bAction *)id);
                        return true;
                case ID_NT:
-                       if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
+                       if (!test) *newid = (ID *)ntreeCopyTree(bmain, (bNodeTree *)id);
                        return true;
                case ID_BR:
-                       if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
+                       if (!test) *newid = (ID *)BKE_brush_copy(bmain, (Brush *)id);
                        return true;
                case ID_PA:
-                       if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
+                       if (!test) *newid = (ID *)BKE_particlesettings_copy(bmain, (ParticleSettings *)id);
                        return true;
                case ID_WM:
                        return false;  /* can't be copied from here */
                case ID_GD:
-                       if (!test) *newid = (ID *)gpencil_data_duplicate((bGPdata *)id, false);
+                       if (!test) *newid = (ID *)gpencil_data_duplicate(bmain, (bGPdata *)id, false);
                        return true;
                case ID_MSK:
-                       if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id);
+                       if (!test) *newid = (ID *)BKE_mask_copy(bmain, (Mask *)id);
                        return true;
                case ID_LS:
-                       if (!test) *newid = (ID *)BKE_linestyle_copy(G.main, (FreestyleLineStyle *)id);
+                       if (!test) *newid = (ID *)BKE_linestyle_copy(bmain, (FreestyleLineStyle *)id);
                        return true;
        }
        
@@ -448,7 +450,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
        if (id) {
                /* if property isn't editable, we're going to have an extra block hanging around until we save */
                if (RNA_property_editable(ptr, prop)) {
-                       if (id_copy(id, &newid, false) && newid) {
+                       if (id_copy(CTX_data_main(C), id, &newid, false) && newid) {
                                /* copy animation actions too */
                                BKE_animdata_copy_id_action(id);
                                /* us is 1 by convention, but RNA_property_pointer_set
@@ -976,7 +978,7 @@ void BKE_libblock_copy_data(ID *id, const ID *id_from, const bool do_action)
 }
 
 /* used everywhere in blenkernel */
-void *BKE_libblock_copy_ex(Main *bmain, ID *id)
+void *BKE_libblock_copy(Main *bmain, ID *id)
 {
        ID *idn;
        size_t idn_len;
@@ -1028,11 +1030,6 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
        return idn;
 }
 
-void *BKE_libblock_copy(ID *id)
-{
-       return BKE_libblock_copy_ex(G.main, id);
-}
-
 static int id_relink_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag)
 {
        ID *id = *id_pointer;
index 2985038bcae1b6a13a046d92d4bde48499060bff..591975b05fa601bc794192fbc328caf92c924467 100644 (file)
@@ -171,7 +171,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *l
                }
        }
        if (linestyle->nodetree) {
-               new_linestyle->nodetree = ntreeCopyTree(linestyle->nodetree);
+               new_linestyle->nodetree = ntreeCopyTree(bmain, linestyle->nodetree);
        }
 
        new_linestyle->r = linestyle->r;
index dabdb4c81c63a0c8bc08ff5800074053e5f7e0ee..f804a4c39198cbe3828465b5216e3b0d5f666222 100644 (file)
@@ -848,11 +848,11 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
        return mask_new;
 }
 
-Mask *BKE_mask_copy(Mask *mask)
+Mask *BKE_mask_copy(Main *bmain, Mask *mask)
 {
        Mask *mask_new;
 
-       mask_new = BKE_libblock_copy(&mask->id);
+       mask_new = BKE_libblock_copy(bmain, &mask->id);
 
        BLI_listbase_clear(&mask_new->masklayers);
 
@@ -862,7 +862,7 @@ Mask *BKE_mask_copy(Mask *mask)
        id_fake_user_set(&mask->id);
 
        if (ID_IS_LINKED_DATABLOCK(mask)) {
-               BKE_id_lib_local_paths(G.main, mask->id.lib, &mask_new->id);
+               BKE_id_lib_local_paths(bmain, mask->id.lib, &mask_new->id);
        }
 
        return mask_new;
index 1b6fd300f67676afa7039d6c0fb1df9f5a4c2ff9..467bf9bf5805487ab0bf7b93ff1604b55397b6d4 100644 (file)
@@ -217,12 +217,12 @@ Material *BKE_material_add(Main *bmain, const char *name)
 }
 
 /* XXX keep synced with next function */
-Material *BKE_material_copy(Material *ma)
+Material *BKE_material_copy(Main *bmain, Material *ma)
 {
        Material *man;
        int a;
        
-       man = BKE_libblock_copy(&ma->id);
+       man = BKE_libblock_copy(bmain, &ma->id);
        
        id_lib_extern((ID *)man->group);
        
@@ -240,13 +240,13 @@ Material *BKE_material_copy(Material *ma)
        if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
 
        if (ma->nodetree) {
-               man->nodetree = ntreeCopyTree(ma->nodetree);
+               man->nodetree = ntreeCopyTree(bmain, ma->nodetree);
        }
 
        BLI_listbase_clear(&man->gpumaterial);
        
        if (ID_IS_LINKED_DATABLOCK(ma)) {
-               BKE_id_lib_local_paths(G.main, ma->id.lib, &man->id);
+               BKE_id_lib_local_paths(bmain, ma->id.lib, &man->id);
        }
 
        return man;
@@ -376,7 +376,7 @@ void BKE_material_make_local(Material *ma)
        }
        /* Both user and local, so copy. */
        else if (is_local && is_lib) {
-               Material *ma_new = BKE_material_copy(ma);
+               Material *ma_new = BKE_material_copy(bmain, ma);
 
                ma_new->id.us = 0;
 
@@ -2161,7 +2161,7 @@ static void convert_tfacematerial(Main *main, Material *ma)
                        }
                        /* create a new material */
                        else {
-                               mat_new = BKE_material_copy(ma);
+                               mat_new = BKE_material_copy(main, ma);
                                if (mat_new) {
                                        /* rename the material*/
                                        BLI_strncpy(mat_new->id.name, idname, sizeof(mat_new->id.name));
index c6e6bb86659a9dd872d45b494c778e18b8b3edde..0a29b2d53fd22e3bcb865e290a90ddf468ece27b 100644 (file)
@@ -102,12 +102,12 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
        return mb;
 }
 
-MetaBall *BKE_mball_copy_ex(Main *bmain, MetaBall *mb)
+MetaBall *BKE_mball_copy(Main *bmain, MetaBall *mb)
 {
        MetaBall *mbn;
        int a;
        
-       mbn = BKE_libblock_copy_ex(bmain, &mb->id);
+       mbn = BKE_libblock_copy(bmain, &mb->id);
 
        BLI_duplicatelist(&mbn->elems, &mb->elems);
        
@@ -126,11 +126,6 @@ MetaBall *BKE_mball_copy_ex(Main *bmain, MetaBall *mb)
        return mbn;
 }
 
-MetaBall *BKE_mball_copy(MetaBall *mb)
-{
-       return BKE_mball_copy_ex(G.main, mb);
-}
-
 static int extern_local_mball_callback(
         void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
 {
@@ -167,7 +162,7 @@ void BKE_mball_make_local(Main *bmain, MetaBall *mb)
                        extern_local_mball(mb);
                }
                else {
-                       MetaBall *mb_new = BKE_mball_copy_ex(bmain, mb);
+                       MetaBall *mb_new = BKE_mball_copy(bmain, mb);
 
                        mb_new->id.us = 0;
 
index b2ab83a70182100b8c7f2e0fa72a2823d93f2f0b..e737696b3af38b153b0a7557f1eb562f0c52d1b2 100644 (file)
@@ -493,7 +493,7 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
        return me;
 }
 
-Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
+Mesh *BKE_mesh_copy(Main *bmain, Mesh *me)
 {
        Mesh *men;
        MTFace *tface;
@@ -501,7 +501,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
        int a, i;
        const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */
        
-       men = BKE_libblock_copy_ex(bmain, &me->id);
+       men = BKE_libblock_copy(bmain, &me->id);
        
        men->mat = MEM_dupallocN(me->mat);
        for (a = 0; a < men->totcol; a++) {
@@ -549,7 +549,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
        men->bb = MEM_dupallocN(men->bb);
        
        if (me->key) {
-               men->key = BKE_key_copy_ex(bmain, me->key);
+               men->key = BKE_key_copy(bmain, me->key);
                men->key->from = (ID *)men;
        }
 
@@ -560,11 +560,6 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
        return men;
 }
 
-Mesh *BKE_mesh_copy(Mesh *me)
-{
-       return BKE_mesh_copy_ex(G.main, me);
-}
-
 BMesh *BKE_mesh_to_bmesh(
         Mesh *me, Object *ob,
         const bool add_key_index, const struct BMeshCreateParams *params)
@@ -650,7 +645,7 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me)
                        expand_local_mesh(me);
                }
                else {
-                       Mesh *me_new = BKE_mesh_copy_ex(bmain, me);
+                       Mesh *me_new = BKE_mesh_copy(bmain, me);
 
                        me_new->id.us = 0;
 
@@ -2338,7 +2333,7 @@ Mesh *BKE_mesh_new_from_object(
                                BKE_object_free_modifiers(tmpobj);
 
                        /* copies the data */
-                       copycu = tmpobj->data = BKE_curve_copy_ex(bmain, (Curve *) ob->data);
+                       copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data);
 
                        /* temporarily set edit so we get updates from edit mode, but
                         * also because for text datablocks copying it while in edit
@@ -2419,7 +2414,7 @@ Mesh *BKE_mesh_new_from_object(
                        /* copies object and modifiers (but not the data) */
                        if (cage) {
                                /* copies the data */
-                               tmpmesh = BKE_mesh_copy_ex(bmain, ob->data);
+                               tmpmesh = BKE_mesh_copy(bmain, ob->data);
                                /* if not getting the original caged mesh, get final derived mesh */
                        }
                        else {
index 992042c8af2535326d4ae2734671f6d6fb811eed..c321bc92a7150ed73b6d483adf988fbddaf58e4f 100644 (file)
@@ -183,7 +183,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action)
                }
                else {
                        /* use a copy of the action instead (user count shouldn't have changed yet) */
-                       strip_d->act = BKE_action_copy(strip_d->act);
+                       strip_d->act = BKE_action_copy(G.main, strip_d->act);
                }
        }
                
index cf70159a3294a4315cfaf9e9d3918e9738640656..aaba5dff7e41028709a5be660f6352b586d7639d 100644 (file)
@@ -1205,7 +1205,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool ski
        
        /* is ntree part of library? */
        if (bmain && !skip_database && BLI_findindex(&bmain->nodetree, ntree) >= 0) {
-               newtree = BKE_libblock_copy(&ntree->id);
+               newtree = BKE_libblock_copy(bmain, &ntree->id);
        }
        else {
                newtree = BKE_libblock_copy_nolib(&ntree->id, true);
@@ -1300,9 +1300,9 @@ bNodeTree *ntreeCopyTree_ex(bNodeTree *ntree, Main *bmain, const bool do_id_user
 {
        return ntreeCopyTree_internal(ntree, bmain, false, do_id_user, true, true);
 }
-bNodeTree *ntreeCopyTree(bNodeTree *ntree)
+bNodeTree *ntreeCopyTree(Main *bmain, bNodeTree *ntree)
 {
-       return ntreeCopyTree_ex(ntree, G.main, true);
+       return ntreeCopyTree_ex(ntree, bmain, true);
 }
 
 /* use when duplicating scenes */
@@ -1995,11 +1995,11 @@ void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
        }
        else if (local && lib) {
                /* this is the mixed case, we copy the tree and assign it to local users */
-               bNodeTree *newtree = ntreeCopyTree(ntree);
+               bNodeTree *newtree = ntreeCopyTree(bmain, ntree);
                
                newtree->id.us = 0;
                
-               FOREACH_NODETREE(G.main, tntree, owner_id) {
+               FOREACH_NODETREE(bmain, tntree, owner_id) {
                        bNode *node;
                        /* find if group is in tree */
                        for (node = tntree->nodes.first; node; node = node->next) {
index 623c437fea5ef834314767e0942952a54f23cf80..4031afb8a7899acdd40df717679a91d4ca8b39c5 100644 (file)
@@ -1094,7 +1094,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
        ModifierData *md;
        int a;
 
-       obn = BKE_libblock_copy_ex(bmain, &ob->id);
+       obn = BKE_libblock_copy(bmain, &ob->id);
        
        if (ob->totcol) {
                obn->mat = MEM_dupallocN(ob->mat);
@@ -1181,9 +1181,9 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
 }
 
 /* copy objects, will re-initialize cached simulation data */
-Object *BKE_object_copy(Object *ob)
+Object *BKE_object_copy(Main *bmain, Object *ob)
 {
-       return BKE_object_copy_ex(G.main, ob, false);
+       return BKE_object_copy_ex(bmain, ob, false);
 }
 
 static int extern_local_object_callback(
@@ -1223,7 +1223,7 @@ void BKE_object_make_local(Main *bmain, Object *ob)
                        extern_local_object(ob);
                }
                else {
-                       Object *ob_new = BKE_object_copy_ex(bmain, ob, false);
+                       Object *ob_new = BKE_object_copy(bmain, ob);
 
                        ob_new->id.us = 0;
                        ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL;
index 4136f866f6ad61831358e94506b63cf9af6f2adc..6e13ce8717292483f4a5de278f102c5284859591 100644 (file)
@@ -3304,12 +3304,12 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
        part->roughcurve = cumap;
 }
 
-ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
+ParticleSettings *BKE_particlesettings_copy(Main *bmain, ParticleSettings *part)
 {
        ParticleSettings *partn;
        int a;
 
-       partn = BKE_libblock_copy(&part->id);
+       partn = BKE_libblock_copy(bmain, &part->id);
        partn->pd = MEM_dupallocN(part->pd);
        partn->pd2 = MEM_dupallocN(part->pd2);
        partn->effector_weights = MEM_dupallocN(part->effector_weights);
@@ -3333,7 +3333,7 @@ ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
        BLI_duplicatelist(&partn->dupliweights, &part->dupliweights);
        
        if (ID_IS_LINKED_DATABLOCK(part)) {
-               BKE_id_lib_local_paths(G.main, part->id.lib, &partn->id);
+               BKE_id_lib_local_paths(bmain, part->id.lib, &partn->id);
        }
 
        return partn;
@@ -3383,7 +3383,7 @@ void BKE_particlesettings_make_local(ParticleSettings *part)
                expand_local_particlesettings(part);
        }
        else if (is_local && is_lib) {
-               ParticleSettings *part_new = BKE_particlesettings_copy(part);
+               ParticleSettings *part_new = BKE_particlesettings_copy(bmain, part);
                part_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
index 0e8efca04d0874d02d0874e244efc3ed8dfd45ba..c071aacc64b8c160dacfc4835b7d5b61ac52b0dc 100644 (file)
@@ -150,7 +150,7 @@ static void remove_sequencer_fcurves(Scene *sce)
        }
 }
 
-Scene *BKE_scene_copy(Scene *sce, int type)
+Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 {
        Scene *scen;
        SceneRenderLayer *srl, *new_srl;
@@ -161,7 +161,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
        if (type == SCE_COPY_EMPTY) {
                ListBase rl, rv;
                /* XXX. main should become an arg */
-               scen = BKE_scene_add(G.main, sce->id.name + 2);
+               scen = BKE_scene_add(bmain, sce->id.name + 2);
                
                rl = scen->r.layers;
                rv = scen->r.views;
@@ -182,10 +182,10 @@ Scene *BKE_scene_copy(Scene *sce, int type)
                BKE_sound_destroy_scene(scen);
        }
        else {
-               scen = BKE_libblock_copy(&sce->id);
+               scen = BKE_libblock_copy(bmain, &sce->id);
                BLI_duplicatelist(&(scen->base), &(sce->base));
                
-               BKE_main_id_clear_newpoins(G.main);
+               BKE_main_id_clear_newpoins(bmain);
                
                id_us_plus((ID *)scen->world);
                id_us_plus((ID *)scen->set);
@@ -209,7 +209,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
 
                if (sce->nodetree) {
                        /* ID's are managed on both copy and switch */
-                       scen->nodetree = ntreeCopyTree(sce->nodetree);
+                       scen->nodetree = ntreeCopyTree(bmain, sce->nodetree);
                        ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
                }
 
@@ -237,7 +237,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
                                for (lineset = new_srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
                                        if (lineset->linestyle) {
                                                id_us_plus((ID *)lineset->linestyle);
-                                               lineset->linestyle = BKE_linestyle_copy(G.main, lineset->linestyle);
+                                               lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle);
                                        }
                                }
                        }
@@ -320,7 +320,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
        if (type == SCE_COPY_FULL) {
                if (scen->world) {
                        id_us_plus((ID *)scen->world);
-                       scen->world = BKE_world_copy(scen->world);
+                       scen->world = BKE_world_copy(bmain, scen->world);
                        BKE_animdata_copy_id_action((ID *)scen->world);
                }
 
@@ -334,7 +334,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
        /* grease pencil */
        if (scen->gpd) {
                if (type == SCE_COPY_FULL) {
-                       scen->gpd = gpencil_data_duplicate(scen->gpd, false);
+                       scen->gpd = gpencil_data_duplicate(bmain, scen->gpd, false);
                }
                else if (type == SCE_COPY_EMPTY) {
                        scen->gpd = NULL;
index 58214e4a8d9e6c9eb071cf109e7d68766eabc740..4cce0851ebcc9b486aa611c2314ae4f9b1b0b477 100644 (file)
@@ -66,11 +66,11 @@ void *BKE_speaker_add(Main *bmain, const char *name)
        return spk;
 }
 
-Speaker *BKE_speaker_copy(Speaker *spk)
+Speaker *BKE_speaker_copy(Main *bmain, Speaker *spk)
 {
        Speaker *spkn;
 
-       spkn = BKE_libblock_copy(&spk->id);
+       spkn = BKE_libblock_copy(bmain, &spk->id);
        if (spkn->sound)
                id_us_plus(&spkn->sound->id);
 
@@ -118,7 +118,7 @@ void BKE_speaker_make_local(Speaker *spk)
                extern_local_speaker(spk);
        }
        else if (is_local && is_lib) {
-               Speaker *spk_new = BKE_speaker_copy(spk);
+               Speaker *spk_new = BKE_speaker_copy(bmain, spk);
                spk_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
index 2b713f980d50c4b0a19cb317ce6b23f7dc07ab62..6beaba1b41c2fe50787b76c823a33e9e4a171f06 100644 (file)
@@ -452,7 +452,7 @@ Text *BKE_text_copy(Main *bmain, Text *ta)
        Text *tan;
        TextLine *line, *tmp;
        
-       tan = BKE_libblock_copy(&ta->id);
+       tan = BKE_libblock_copy(bmain, &ta->id);
        
        /* file name can be NULL */
        if (ta->name) {
index a8657dd2cb0ebd015b3ee76134bd482e06ad0213..877bc0c02b0eabb637e66d5fbc64b69aa8229372 100644 (file)
@@ -844,11 +844,11 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
 
 /* ------------------------------------------------------------------------- */
 
-Tex *BKE_texture_copy(Tex *tex)
+Tex *BKE_texture_copy(Main *bmain, Tex *tex)
 {
        Tex *texn;
        
-       texn = BKE_libblock_copy(&tex->id);
+       texn = BKE_libblock_copy(bmain, &tex->id);
        if (BKE_texture_is_image_user(tex)) {
                id_us_plus((ID *)texn->ima);
        }
@@ -867,11 +867,11 @@ Tex *BKE_texture_copy(Tex *tex)
                if (tex->nodetree->execdata) {
                        ntreeTexEndExecTree(tex->nodetree->execdata);
                }
-               texn->nodetree = ntreeCopyTree(tex->nodetree);
+               texn->nodetree = ntreeCopyTree(bmain, tex->nodetree);
        }
        
        if (ID_IS_LINKED_DATABLOCK(tex)) {
-               BKE_id_lib_local_paths(G.main, tex->id.lib, &texn->id);
+               BKE_id_lib_local_paths(bmain, tex->id.lib, &texn->id);
        }
 
        return texn;
@@ -1011,7 +1011,7 @@ void BKE_texture_make_local(Tex *tex)
                extern_local_texture(tex);
        }
        else if (is_local && is_lib) {
-               Tex *tex_new = BKE_texture_copy(tex);
+               Tex *tex_new = BKE_texture_copy(bmain, tex);
 
                tex_new->id.us = 0;
 
index c6ab843b38a6b452568173076583d5fd5a30aeca..cfd10e7ba35f3fa201b36cc2f7d7df0ae8addbc7 100644 (file)
@@ -117,12 +117,12 @@ World *add_world(Main *bmain, const char *name)
        return wrld;
 }
 
-World *BKE_world_copy(World *wrld)
+World *BKE_world_copy(Main *bmain, World *wrld)
 {
        World *wrldn;
        int a;
        
-       wrldn = BKE_libblock_copy(&wrld->id);
+       wrldn = BKE_libblock_copy(bmain, &wrld->id);
        
        for (a = 0; a < MAX_MTEX; a++) {
                if (wrld->mtex[a]) {
@@ -133,7 +133,7 @@ World *BKE_world_copy(World *wrld)
        }
 
        if (wrld->nodetree) {
-               wrldn->nodetree = ntreeCopyTree(wrld->nodetree);
+               wrldn->nodetree = ntreeCopyTree(bmain, wrld->nodetree);
        }
        
        if (wrld->preview)
@@ -142,7 +142,7 @@ World *BKE_world_copy(World *wrld)
        BLI_listbase_clear(&wrldn->gpumaterial);
 
        if (ID_IS_LINKED_DATABLOCK(wrld)) {
-               BKE_id_lib_local_paths(G.main, wrld->id.lib, &wrldn->id);
+               BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrldn->id);
        }
 
        return wrldn;
@@ -202,7 +202,7 @@ void BKE_world_make_local(World *wrld)
                id_clear_lib_data(bmain, &wrld->id);
        }
        else if (is_local && is_lib) {
-               World *wrld_new = BKE_world_copy(wrld);
+               World *wrld_new = BKE_world_copy(bmain, wrld);
                wrld_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
index 3a709da78e1a0591b7877a9c3b856e3d837aaf52..f06f299d381e33a9c749a6d1fb6f31230f5a3202 100644 (file)
@@ -416,7 +416,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
 {
        fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
 
-       Object *obn = BKE_object_copy(source_ob);
+       Object *obn = BKE_object_copy(G.main, source_ob);
        DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
        BKE_scene_base_add(sce, obn);
 
index 9e04f410333fa1ed293610ef6b0e1126073055d1..72b48a32477171cd59cb77d1a668bd5dba91d2f9 100644 (file)
@@ -1301,7 +1301,7 @@ static int separate_exec(bContext *C, wmOperator *op)
        DAG_relations_tag_update(bmain);
 
        newob = newbase->object;
-       newcu = newob->data = BKE_curve_copy_ex(bmain, oldcu);
+       newcu = newob->data = BKE_curve_copy(bmain, oldcu);
        newcu->editnurb = NULL;
        id_us_min(&oldcu->id); /* because new curve is a copy: reduce user count */
 
index c39a3aa5cfc2acb03bf9209fa81aba00dc252d92..f9b479ca03d0dfecdbdbc271c91714a55a99e872 100644 (file)
@@ -43,7 +43,9 @@
 
 #include "BKE_blender_undo.h"
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_gpencil.h"
+#include "BKE_main.h"
 
 #include "ED_gpencil.h"
 
@@ -151,7 +153,7 @@ void gpencil_undo_push(bGPdata *gpd)
        
        /* create new undo node */
        undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
-       undo_node->gpd = gpencil_data_duplicate(gpd, true);
+       undo_node->gpd = gpencil_data_duplicate(G.main, gpd, true);
        
        cur_node = undo_node;
        
index 77dc822fd4033469e213fa18d53eeb0c1e634f43..d91bd498225a65699c1ef6e118437ca6c78faf3e 100644 (file)
@@ -475,7 +475,7 @@ static void template_ID(
 
                        UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
                        if (/* test only */
-                           (id_copy(id, NULL, true) == false) ||
+                           (id_copy(CTX_data_main(C), id, NULL, true) == false) ||
                            (idfrom && idfrom->lib) ||
                            (!editable) ||
                            /* object in editmode - don't change data */
index 1b5fc4e8a1c9b3326b838af5b2072ceb044bf1c5..b26989113d4a0bb556249189114567b0252d115d 100644 (file)
@@ -172,7 +172,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
         */
        if (key) {
                /* make a duplicate copy that will only be used here... (must remember to free it!) */
-               nkey = BKE_key_copy_ex(bmain, key);
+               nkey = BKE_key_copy(bmain, key);
                
                /* for all keys in old block, clear data-arrays */
                for (kb = key->block.first; kb; kb = kb->next) {
index 2ea39209781689513a6ccf2d0e46bd4a6d2af6ed..cc628210e20081f477e339eb9222c835d13849fb 100644 (file)
@@ -1299,7 +1299,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
 
        for (dob = lb->first; dob; dob = dob->next) {
                Base *basen;
-               Object *ob = BKE_object_copy(dob->ob);
+               Object *ob = BKE_object_copy(bmain, dob->ob);
 
                /* font duplis can have a totcol without material, we get them from parent
                 * should be implemented better...
@@ -1520,7 +1520,7 @@ static int convert_poll(bContext *C)
 }
 
 /* Helper for convert_exec */
-static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob)
+static Base *duplibase_for_convert(Main *bmain, Scene *scene, Base *base, Object *ob)
 {
        Object *obn;
        Base *basen;
@@ -1529,7 +1529,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob)
                ob = base->object;
        }
 
-       obn = BKE_object_copy(ob);
+       obn = BKE_object_copy(bmain, ob);
        DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
 
        basen = MEM_mallocN(sizeof(Base), "duplibase");
@@ -1609,7 +1609,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                        ob->flag |= OB_DONE;
 
                        if (keep_original) {
-                               basen = duplibase_for_convert(scene, base, NULL);
+                               basen = duplibase_for_convert(bmain, scene, base, NULL);
                                newob = basen->object;
 
                                /* decrement original mesh's usage count  */
@@ -1617,7 +1617,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                                id_us_min(&me->id);
 
                                /* make a new copy of the mesh */
-                               newob->data = BKE_mesh_copy(me);
+                               newob->data = BKE_mesh_copy(bmain, me);
                        }
                        else {
                                newob = ob;
@@ -1634,7 +1634,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                        ob->flag |= OB_DONE;
 
                        if (keep_original) {
-                               basen = duplibase_for_convert(scene, base, NULL);
+                               basen = duplibase_for_convert(bmain, scene, base, NULL);
                                newob = basen->object;
 
                                /* decrement original mesh's usage count  */
@@ -1642,7 +1642,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                                id_us_min(&me->id);
 
                                /* make a new copy of the mesh */
-                               newob->data = BKE_mesh_copy(me);
+                               newob->data = BKE_mesh_copy(bmain, me);
                        }
                        else {
                                newob = ob;
@@ -1666,14 +1666,14 @@ static int convert_exec(bContext *C, wmOperator *op)
                        ob->flag |= OB_DONE;
 
                        if (keep_original) {
-                               basen = duplibase_for_convert(scene, base, NULL);
+                               basen = duplibase_for_convert(bmain, scene, base, NULL);
                                newob = basen->object;
 
                                /* decrement original curve's usage count  */
                                id_us_min(&((Curve *)newob->data)->id);
 
                                /* make a new copy of the curve */
-                               newob->data = BKE_curve_copy_ex(bmain, ob->data);
+                               newob->data = BKE_curve_copy(bmain, ob->data);
                        }
                        else {
                                newob = ob;
@@ -1737,14 +1737,14 @@ static int convert_exec(bContext *C, wmOperator *op)
 
                        if (target == OB_MESH) {
                                if (keep_original) {
-                                       basen = duplibase_for_convert(scene, base, NULL);
+                                       basen = duplibase_for_convert(bmain, scene, base, NULL);
                                        newob = basen->object;
 
                                        /* decrement original curve's usage count  */
                                        id_us_min(&((Curve *)newob->data)->id);
 
                                        /* make a new copy of the curve */
-                                       newob->data = BKE_curve_copy_ex(bmain, ob->data);
+                                       newob->data = BKE_curve_copy(bmain, ob->data);
                                }
                                else {
                                        newob = ob;
@@ -1772,7 +1772,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                        if (!(baseob->flag & OB_DONE)) {
                                baseob->flag |= OB_DONE;
 
-                               basen = duplibase_for_convert(scene, base, baseob);
+                               basen = duplibase_for_convert(bmain, scene, base, baseob);
                                newob = basen->object;
 
                                mb = newob->data;
@@ -1910,7 +1910,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                ; /* nothing? */
        }
        else {
-               obn = BKE_object_copy(ob);
+               obn = BKE_object_copy(bmain, ob);
                DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
 
                basen = MEM_mallocN(sizeof(Base), "duplibase");
@@ -1941,7 +1941,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (id) {
                                        ID_NEW_US(obn->mat[a])
                                        else
-                                               obn->mat[a] = BKE_material_copy(obn->mat[a]);
+                                               obn->mat[a] = BKE_material_copy(bmain, obn->mat[a]);
                                        id_us_min(id);
 
                                        if (dupflag & USER_DUP_ACT) {
@@ -1957,7 +1957,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (id) {
                                        ID_NEW_US(psys->part)
                                        else
-                                               psys->part = BKE_particlesettings_copy(psys->part);
+                                               psys->part = BKE_particlesettings_copy(bmain, psys->part);
 
                                        if (dupflag & USER_DUP_ACT) {
                                                BKE_animdata_copy_id_action(&psys->part->id);
@@ -1976,7 +1976,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_MESH) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_mesh_copy(obn->data);
+                                               obn->data = BKE_mesh_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -1986,7 +1986,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_CURVE) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_curve_copy_ex(bmain, obn->data);
+                                               obn->data = BKE_curve_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -1996,7 +1996,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_SURF) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_curve_copy_ex(bmain, obn->data);
+                                               obn->data = BKE_curve_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2006,7 +2006,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_FONT) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_curve_copy_ex(bmain, obn->data);
+                                               obn->data = BKE_curve_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2016,7 +2016,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_MBALL) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_mball_copy_ex(bmain, obn->data);
+                                               obn->data = BKE_mball_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2026,7 +2026,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_LAMP) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_lamp_copy(obn->data);
+                                               obn->data = BKE_lamp_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2039,7 +2039,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag & USER_DUP_ARM) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_armature_copy(obn->data);
+                                               obn->data = BKE_armature_copy(bmain, obn->data);
                                                BKE_pose_rebuild(obn, obn->data);
                                                didit = 1;
                                        }
@@ -2050,7 +2050,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag != 0) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_lattice_copy_ex(bmain, obn->data);
+                                               obn->data = BKE_lattice_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2060,7 +2060,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag != 0) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_camera_copy(obn->data);
+                                               obn->data = BKE_camera_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2070,7 +2070,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                if (dupflag != 0) {
                                        ID_NEW_US2(obn->data)
                                        else {
-                                               obn->data = BKE_speaker_copy(obn->data);
+                                               obn->data = BKE_speaker_copy(bmain, obn->data);
                                                didit = 1;
                                        }
                                        id_us_min(id);
@@ -2109,7 +2109,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                                                if (id) {
                                                        ID_NEW_US((*matarar)[a])
                                                        else
-                                                               (*matarar)[a] = BKE_material_copy((*matarar)[a]);
+                                                               (*matarar)[a] = BKE_material_copy(bmain, (*matarar)[a]);
                                                        id_us_min(id);
                                                }
                                        }
index bf2dc55006768e4ced06c27b399deb64eae60870..6b16e19f79087d3f74aa1f47f0b3d1955299b280 100644 (file)
@@ -1751,7 +1751,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
                if ((base->flag & flag) == flag) {
                        if (!ID_IS_LINKED_DATABLOCK(ob) && ob->id.us > 1) {
                                /* base gets copy of object */
-                               obn = BKE_object_copy(ob);
+                               obn = BKE_object_copy(bmain, ob);
                                base->object = obn;
 
                                if (copy_groups) {
@@ -1784,7 +1784,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
                        }
 
                        if (all_duplicated) {
-                               groupn = BKE_group_copy(group);
+                               groupn = BKE_group_copy(bmain, group);
 
                                for (go = groupn->gobject.first; go; go = go->next)
                                        go->ob = (Object *)go->ob->id.newid;
@@ -1821,7 +1821,7 @@ void ED_object_single_user(Main *bmain, Scene *scene, Object *ob)
        single_object_users(bmain, scene, NULL, OB_DONE, copy_groups);
 }
 
-static void new_id_matar(Material **matar, const int totcol)
+static void new_id_matar(Main *bmain, Material **matar, const int totcol)
 {
        ID *id;
        int a;
@@ -1835,7 +1835,7 @@ static void new_id_matar(Material **matar, const int totcol)
                                id_us_min(id);
                        }
                        else if (id->us > 1) {
-                               matar[a] = BKE_material_copy(matar[a]);
+                               matar[a] = BKE_material_copy(bmain, matar[a]);
                                id_us_min(id);
                                id->newid = (ID *)matar[a];
                        }
@@ -1865,7 +1865,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
 
                                switch (ob->type) {
                                        case OB_LAMP:
-                                               ob->data = la = BKE_lamp_copy(ob->data);
+                                               ob->data = la = BKE_lamp_copy(bmain, ob->data);
                                                for (a = 0; a < MAX_MTEX; a++) {
                                                        if (la->mtex[a]) {
                                                                ID_NEW(la->mtex[a]->object);
@@ -1873,37 +1873,37 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
                                                }
                                                break;
                                        case OB_CAMERA:
-                                               ob->data = BKE_camera_copy(ob->data);
+                                               ob->data = BKE_camera_copy(bmain, ob->data);
                                                break;
                                        case OB_MESH:
-                                               ob->data = me = BKE_mesh_copy(ob->data);
+                                               ob->data = me = BKE_mesh_copy(bmain, ob->data);
                                                if (me->key)
                                                        BKE_animdata_copy_id_action((ID *)me->key);
                                                break;
                                        case OB_MBALL:
-                                               ob->data = BKE_mball_copy_ex(bmain, ob->data);
+                                               ob->data = BKE_mball_copy(bmain, ob->data);
                                                break;
                                        case OB_CURVE:
                                        case OB_SURF:
                                        case OB_FONT:
-                                               ob->data = cu = BKE_curve_copy_ex(bmain, ob->data);
+                                               ob->data = cu = BKE_curve_copy(bmain, ob->data);
                                                ID_NEW(cu->bevobj);
                                                ID_NEW(cu->taperobj);
                                                if (cu->key)
                                                        BKE_animdata_copy_id_action((ID *)cu->key);
                                                break;
                                        case OB_LATTICE:
-                                               ob->data = lat = BKE_lattice_copy_ex(bmain, ob->data);
+                                               ob->data = lat = BKE_lattice_copy(bmain, ob->data);
                                                if (lat->key)
                                                        BKE_animdata_copy_id_action((ID *)lat->key);
                                                break;
                                        case OB_ARMATURE:
                                                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-                                               ob->data = BKE_armature_copy(ob->data);
+                                               ob->data = BKE_armature_copy(bmain, ob->data);
                                                BKE_pose_rebuild(ob, ob->data);
                                                break;
                                        case OB_SPEAKER:
-                                               ob->data = BKE_speaker_copy(ob->data);
+                                               ob->data = BKE_speaker_copy(bmain, ob->data);
                                                break;
                                        default:
                                                if (G.debug & G_DEBUG)
@@ -1945,7 +1945,7 @@ static void single_object_action_users(Scene *scene, const int flag)
        }
 }
 
-static void single_mat_users(Scene *scene, const int flag, const bool do_textures)
+static void single_mat_users(Main *bmain, Scene *scene, const int flag, const bool do_textures)
 {
        Object *ob;
        Base *base;
@@ -1962,7 +1962,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture
                                        /* do not test for LIB_TAG_NEW: this functions guaranteed delivers single_users! */
 
                                        if (ma->id.us > 1) {
-                                               man = BKE_material_copy(ma);
+                                               man = BKE_material_copy(bmain, ma);
                                                BKE_animdata_copy_id_action(&man->id);
 
                                                man->id.us = 0;
@@ -1973,7 +1973,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture
                                                                if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) {
                                                                        if (tex->id.us > 1) {
                                                                                id_us_min(&tex->id);
-                                                                               tex = BKE_texture_copy(tex);
+                                                                               tex = BKE_texture_copy(bmain, tex);
                                                                                BKE_animdata_copy_id_action(&tex->id);
                                                                                man->mtex[b]->tex = tex;
                                                                        }
@@ -1987,7 +1987,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture
        }
 }
 
-static void do_single_tex_user(Tex **from)
+static void do_single_tex_user(Main *bmain, Tex **from)
 {
        Tex *tex, *texn;
 
@@ -2000,7 +2000,7 @@ static void do_single_tex_user(Tex **from)
                id_us_min(&tex->id);
        }
        else if (tex->id.us > 1) {
-               texn = BKE_texture_copy(tex);
+               texn = BKE_texture_copy(bmain, tex);
                BKE_animdata_copy_id_action(&texn->id);
                tex->id.newid = (ID *)texn;
                id_us_min(&tex->id);
@@ -2020,7 +2020,7 @@ static void single_tex_users_expand(Main *bmain)
                if (ma->id.tag & LIB_TAG_NEW) {
                        for (b = 0; b < MAX_MTEX; b++) {
                                if (ma->mtex[b] && ma->mtex[b]->tex) {
-                                       do_single_tex_user(&(ma->mtex[b]->tex));
+                                       do_single_tex_user(bmain, &(ma->mtex[b]->tex));
                                }
                        }
                }
@@ -2030,7 +2030,7 @@ static void single_tex_users_expand(Main *bmain)
                if (la->id.tag & LIB_TAG_NEW) {
                        for (b = 0; b < MAX_MTEX; b++) {
                                if (la->mtex[b] && la->mtex[b]->tex) {
-                                       do_single_tex_user(&(la->mtex[b]->tex));
+                                       do_single_tex_user(bmain, &(la->mtex[b]->tex));
                                }
                        }
                }
@@ -2040,7 +2040,7 @@ static void single_tex_users_expand(Main *bmain)
                if (wo->id.tag & LIB_TAG_NEW) {
                        for (b = 0; b < MAX_MTEX; b++) {
                                if (wo->mtex[b] && wo->mtex[b]->tex) {
-                                       do_single_tex_user(&(wo->mtex[b]->tex));
+                                       do_single_tex_user(bmain, &(wo->mtex[b]->tex));
                                }
                        }
                }
@@ -2059,19 +2059,19 @@ static void single_mat_users_expand(Main *bmain)
 
        for (ob = bmain->object.first; ob; ob = ob->id.next)
                if (ob->id.tag & LIB_TAG_NEW)
-                       new_id_matar(ob->mat, ob->totcol);
+                       new_id_matar(bmain, ob->mat, ob->totcol);
 
        for (me = bmain->mesh.first; me; me = me->id.next)
                if (me->id.tag & LIB_TAG_NEW)
-                       new_id_matar(me->mat, me->totcol);
+                       new_id_matar(bmain, me->mat, me->totcol);
 
        for (cu = bmain->curve.first; cu; cu = cu->id.next)
                if (cu->id.tag & LIB_TAG_NEW)
-                       new_id_matar(cu->mat, cu->totcol);
+                       new_id_matar(bmain, cu->mat, cu->totcol);
 
        for (mb = bmain->mball.first; mb; mb = mb->id.next)
                if (mb->id.tag & LIB_TAG_NEW)
-                       new_id_matar(mb->mat, mb->totcol);
+                       new_id_matar(bmain, mb->mat, mb->totcol);
 
        /* material imats  */
        for (ma = bmain->mat.first; ma; ma = ma->id.next)
@@ -2376,7 +2376,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
        }
 
        if (RNA_boolean_get(op->ptr, "material")) {
-               single_mat_users(scene, flag, RNA_boolean_get(op->ptr, "texture"));
+               single_mat_users(bmain, scene, flag, RNA_boolean_get(op->ptr, "texture"));
        }
 
 #if 0 /* can't do this separate from materials */
index d6c89b9c7a5bf9703a5ec8349abed5c46159e7ea..0dd00df6182ca93b26fc84a6142c2fea443b43e7 100644 (file)
@@ -195,7 +195,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* add or copy particle setting */
        if (psys->part)
-               part= BKE_particlesettings_copy(psys->part);
+               part= BKE_particlesettings_copy(bmain, psys->part);
        else
                part= psys_new_settings("ParticleSettings", bmain);
 
index 1d20ecf2d99f7a821c24f0b00669ba14e68b1b23..c3f831387078242956556c1d39bc6de9133eb744 100644 (file)
@@ -464,7 +464,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* add or copy material */
        if (ma) {
-               ma = BKE_material_copy(ma);
+               ma = BKE_material_copy(bmain, ma);
        }
        else {
                ma = BKE_material_add(bmain, DATA_("Material"));
@@ -518,7 +518,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* add or copy texture */
        if (tex) {
-               tex = BKE_texture_copy(tex);
+               tex = BKE_texture_copy(bmain, tex);
        }
        else {
                tex = BKE_texture_add(bmain, DATA_("Texture"));
@@ -576,7 +576,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* add or copy world */
        if (wo) {
-               wo = BKE_world_copy(wo);
+               wo = BKE_world_copy(bmain, wo);
        }
        else {
                wo = add_world(bmain, DATA_("World"));
index 04a8f0a3a5188d55334bf18643090d9060a3ffc1..6dbb5db53d0aac2b9ed82a838077dda4ffc05e39 100644 (file)
@@ -3955,7 +3955,7 @@ static int scene_new_exec(bContext *C, wmOperator *op)
                newscene = BKE_scene_add(bmain, DATA_("Scene"));
        }
        else { /* different kinds of copying */
-               newscene = BKE_scene_copy(scene, type);
+               newscene = BKE_scene_copy(bmain, scene, type);
 
                /* these can't be handled in blenkernel currently, so do them here */
                if (type == SCE_COPY_LINK_DATA) {
index bf923415f011d7877a3edbd79d8cb0c5480f82b5..f88b64129e7cd0591a7d98e83d06b19b4583aee8 100644 (file)
@@ -69,7 +69,7 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
        PaintMode mode = BKE_paintmode_get_active_from_context(C);
 
        if (br)
-               br = BKE_brush_copy(br);
+               br = BKE_brush_copy(bmain, br);
        else
                br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paint_mode(mode));
 
index a3be7791f9a6baf159ac878f904a2f236dfcf3cd..6755a6316ccea3de18a55016d4a0b6a27882e5fe 100644 (file)
@@ -121,7 +121,7 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
         */
        if (oldact && GS(oldact->id.name) == ID_AC) {
                /* make a copy of the existing action */
-               action = BKE_action_copy(oldact);
+               action = BKE_action_copy(CTX_data_main(C), oldact);
        }
        else {
                /* just make a new (empty) action */
index a21596963943d89de2473e4e3bb31b72ed8bd59c..3e7e8ccc3f4a01629894ed5ef99add4dfb565716 100644 (file)
@@ -1856,6 +1856,7 @@ void NLA_OT_action_sync_length(wmOperatorType *ot)
 
 static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        bAnimContext ac;
        
        ListBase anim_data = {NULL, NULL};
@@ -1887,7 +1888,7 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
                                /* multi-user? */
                                if (ID_REAL_USERS(strip->act) > 1) {
                                        /* make a new copy of the action for us to use (it will have 1 user already) */
-                                       bAction *new_action = BKE_action_copy(strip->act);
+                                       bAction *new_action = BKE_action_copy(bmain, strip->act);
                                        
                                        /* decrement user count of our existing action */
                                        id_us_min(&strip->act->id);
@@ -1945,6 +1946,7 @@ static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt)
 
 static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        bAnimContext ac;
        
        ListBase anim_data = {NULL, NULL};
@@ -1974,7 +1976,7 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
                                        continue;
                                if (strip->act->id.us > 1) {
                                        /* make a copy of the Action to work on */
-                                       bAction *act = BKE_action_copy(strip->act);
+                                       bAction *act = BKE_action_copy(bmain, strip->act);
                                        
                                        /* set this as the new referenced action, decrementing the users of the old one */
                                        id_us_min(&strip->act->id);
index 5c58e9b720cc35023c653042e808c817fe246fa1..cf6e2ac226e301a2b51905ab17cfd2a299433b06 100644 (file)
@@ -255,7 +255,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
                bAction *waction;
 
                /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
-               waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action);
+               waction = wgroup->adt->action = BKE_action_copy(G.main, wgroup->adt->action);
                
                /* now perform the moving */
                BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
index dc6d30854a60caebba850bf0b4698ab00ad798e0..d67929b65fc1b53713abf1c0e2d2e84261473eb9 100644 (file)
@@ -277,11 +277,11 @@ StructRNA *rna_PropertyGroup_refine(PointerRNA *ptr)
        return ptr->type;
 }
 
-static ID *rna_ID_copy(ID *id)
+static ID *rna_ID_copy(ID *id, Main *bmain)
 {
        ID *newid;
 
-       if (id_copy(id, &newid, false)) {
+       if (id_copy(bmain, id, &newid, false)) {
                if (newid) id_us_min(newid);
                return newid;
        }
@@ -981,6 +981,7 @@ static void rna_def_ID(BlenderRNA *brna)
        /* functions */
        func = RNA_def_function(srna, "copy", "rna_ID_copy");
        RNA_def_function_ui_description(func, "Create a copy of this data-block (not supported for all data-blocks)");
+       RNA_def_function_flag(func, FUNC_USE_MAIN);
        parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
        RNA_def_function_return(func, parm);
 
index a1819a8dc92a91397c773f66ab165b3cfed2d6a6..a5af525e13ac92006d40eb980f91a68e25715f4b 100644 (file)
@@ -233,8 +233,8 @@ BL_ArmatureObject::BL_ArmatureObject(
        m_lastapplyframe(0.0)
 {
        m_origObjArma = armature; // Keep a copy of the original armature so we can fix drivers later
-       m_objArma = BKE_object_copy(armature);
-       m_objArma->data = BKE_armature_copy((bArmature *)armature->data);
+       m_objArma = BKE_object_copy(G.main, armature);
+       m_objArma->data = BKE_armature_copy(G.main, (bArmature *)armature->data);
        // During object replication ob->data is increase, we decrease it now because we get a copy.
        id_us_min(&((bArmature *)m_origObjArma->data)->id);
        m_pose = m_objArma->pose;
@@ -433,8 +433,8 @@ void BL_ArmatureObject::ProcessReplica()
        KX_GameObject::ProcessReplica();
 
        bArmature* tmp = (bArmature*)m_objArma->data;
-       m_objArma = BKE_object_copy(m_objArma);
-       m_objArma->data = BKE_armature_copy(tmp);
+       m_objArma = BKE_object_copy(G.main, m_objArma);
+       m_objArma->data = BKE_armature_copy(G.main, tmp);
        m_pose = m_objArma->pose;
 }
 
index ef9e9544c30fa8d4c4dd175f6270bd4db59fb978..94256a64d75ed6383a433da47c772b2709aad582 100644 (file)
@@ -75,7 +75,7 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
       m_useShapeDrivers(false),
       m_lastShapeUpdate(-1)
 {
-       m_key = m_bmesh->key ? BKE_key_copy(m_bmesh->key) : NULL;
+       m_key = m_bmesh->key ? BKE_key_copy(G.main, m_bmesh->key) : NULL;
 };
 
 /* this second constructor is needed for making a mesh deformable on the fly. */
@@ -91,7 +91,7 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
                                        m_useShapeDrivers(false),
                                        m_lastShapeUpdate(-1)
 {
-       m_key = m_bmesh->key ? BKE_key_copy(m_bmesh->key) : NULL;
+       m_key = m_bmesh->key ? BKE_key_copy(G.main, m_bmesh->key) : NULL;
 };
 
 BL_ShapeDeformer::~BL_ShapeDeformer()
@@ -117,7 +117,7 @@ void BL_ShapeDeformer::ProcessReplica()
        BL_SkinDeformer::ProcessReplica();
        m_lastShapeUpdate = -1;
 
-       m_key = m_key ? BKE_key_copy(m_key) : NULL;
+       m_key = m_key ? BKE_key_copy(G.main, m_key) : NULL;
 }
 
 bool BL_ShapeDeformer::LoadShapeDrivers(KX_GameObject* parent)
index b97d0b2a85da15767b35daaf01387b267581d80a..08b569fa4c28d0c2903d68ad33738e64315a48e6 100644 (file)
@@ -1425,7 +1425,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene *kx_scene,
 #ifdef DEBUG
                printf("Mesh has a user \"%s\"\n", name);
 #endif
-               me = (ID*)BKE_mesh_copy_ex(from_maggie, (Mesh*)me);
+               me = (ID*)BKE_mesh_copy(from_maggie, (Mesh*)me);
                id_us_min(me);
        }
        BLI_remlink(&from_maggie->mesh, me); /* even if we made the copy it needs to be removed */
@@ -1447,12 +1447,12 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene *kx_scene,
                        /* if its tagged its a replaced material */
                        if (mat_old && (mat_old->id.tag & LIB_TAG_DOIT) == 0) {
                                Material *mat_old = mesh->mat[i];
-                               Material *mat_new = BKE_material_copy(mat_old);
+                               Material *mat_new = BKE_material_copy(from_maggie, mat_old);
 
                                mat_new->id.tag |= LIB_TAG_DOIT;
                                id_us_min(&mat_old->id);
 
-                               BLI_remlink(&G.main->mat, mat_new); // BKE_material_copy uses G.main, and there is no BKE_material_copy_ex
+                               BLI_remlink(&from_maggie->mat, mat_new); // BKE_material_copy uses G.main, and there is no BKE_material_copy_ex
                                BLI_addtail(&maggie->mat, mat_new);
 
                                mesh->mat[i] = mat_new;
index 45946f308271f1332349122c14d237fdba0a6e30..7175eb877dd9cc979d1d504ebb79db8b227ee524 100644 (file)
@@ -161,7 +161,7 @@ bool BL_Action::Play(const char* name,
                BKE_libblock_free(G.main, m_tmpaction);
                m_tmpaction = NULL;
        }
-       m_tmpaction = BKE_action_copy(m_action);
+       m_tmpaction = BKE_action_copy(G.main, m_action);
 
        // First get rid of any old controllers
        ClearControllerList();