diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_icons.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/icons.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lamp.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/world.c | 2 |
8 files changed, 28 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 7839b9e2154..efef8d4be78 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -99,6 +99,8 @@ struct PreviewImage *BKE_previewimg_create(void); /* create a copy of the preview image */ struct PreviewImage *BKE_previewimg_copy(struct PreviewImage *prv); +void BKE_previewimg_id_copy(struct ID *new_id, struct ID *old_id); + /* retrieve existing or create new preview image */ struct PreviewImage *BKE_previewimg_id_ensure(struct ID *id); diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 63055dc0646..2d5b15c8f9d 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -221,6 +221,24 @@ PreviewImage *BKE_previewimg_copy(PreviewImage *prv) return prv_img; } +/** Duplicate preview image from \a id and clear icon_id, to be used by datablock copy functions. */ +void BKE_previewimg_id_copy(ID *new_id, ID *old_id) +{ + PreviewImage **old_prv_p = BKE_previewimg_id_get_p(old_id); + PreviewImage **new_prv_p = BKE_previewimg_id_get_p(new_id); + + if (old_prv_p && *old_prv_p) { + BLI_assert(new_prv_p != NULL && ELEM(*new_prv_p, NULL, *old_prv_p)); +// const int new_icon_id = get_next_free_id(); + +// if (new_icon_id == 0) { +// return; /* Failure. */ +// } + *new_prv_p = BKE_previewimg_copy(*old_prv_p); + new_id->icon_id = (*new_prv_p)->icon_id = 0; + } +} + PreviewImage **BKE_previewimg_id_get_p(ID *id) { switch (GS(id->name)) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7cf2b9558cb..0032eb35d3a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -459,7 +459,7 @@ Image *BKE_image_copy(Main *bmain, Image *ima) nima->stereo3d_format = MEM_dupallocN(ima->stereo3d_format); BLI_duplicatelist(&nima->views, &ima->views); - nima->preview = BKE_previewimg_copy(ima->preview); + BKE_previewimg_id_copy(&nima->id, &ima->id); if (ID_IS_LINKED_DATABLOCK(ima)) { BKE_id_expand_local(&nima->id); diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index c224b5ca0a7..81bcdbde1dc 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -135,8 +135,8 @@ Lamp *BKE_lamp_copy(Main *bmain, Lamp *la) if (la->nodetree) lan->nodetree = ntreeCopyTree(bmain, la->nodetree); - - lan->preview = BKE_previewimg_copy(la->preview); + + BKE_previewimg_id_copy(&lan->id, &la->id); if (ID_IS_LINKED_DATABLOCK(la)) { BKE_id_expand_local(&lan->id); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2ae369fdd1b..75fa42f1b61 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -243,7 +243,7 @@ Material *BKE_material_copy(Main *bmain, Material *ma) man->nodetree = ntreeCopyTree(bmain, ma->nodetree); } - man->preview = BKE_previewimg_copy(ma->preview); + BKE_previewimg_id_copy(&man->id, &ma->id); BLI_listbase_clear(&man->gpumaterial); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 11b60e1301d..d3c4ed82c3d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -344,7 +344,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) } } - scen->preview = BKE_previewimg_copy(sce->preview); + BKE_previewimg_id_copy(&scen->id, &sce->id); return scen; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 460417cc2c0..ecc169077cd 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -863,7 +863,6 @@ Tex *BKE_texture_copy(Main *bmain, Tex *tex) if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd); if (texn->vd) texn->vd = MEM_dupallocN(texn->vd); if (texn->ot) texn->ot = BKE_texture_ocean_copy(texn->ot); - if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if (tex->nodetree) { if (tex->nodetree->execdata) { @@ -871,8 +870,8 @@ Tex *BKE_texture_copy(Main *bmain, Tex *tex) } texn->nodetree = ntreeCopyTree(bmain, tex->nodetree); } - - texn->preview = BKE_previewimg_copy(tex->preview); + + BKE_previewimg_id_copy(&texn->id, &tex->id); if (ID_IS_LINKED_DATABLOCK(tex)) { BKE_id_expand_local(&texn->id); diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 277aeaa7e42..f926e29ea84 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -138,7 +138,7 @@ World *BKE_world_copy(Main *bmain, World *wrld) wrldn->nodetree = ntreeCopyTree(bmain, wrld->nodetree); } - wrldn->preview = BKE_previewimg_copy(wrld->preview); + BKE_previewimg_id_copy(&wrldn->id, &wrld->id); BLI_listbase_clear(&wrldn->gpumaterial); |