diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-10-08 12:29:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-10-08 12:29:49 +0300 |
commit | 97b6948181df4ee97296ec45aebc75f31b7c790a (patch) | |
tree | f2dbe2c2ba99abb1a0ee832268bb97d6fd4a4a22 /source/blender/blenkernel/intern/library.c | |
parent | 5eb500f2fce12f0b9a042480d0d4bf5000907726 (diff) |
Fix T46386: Duplicate fails updating driver links
Duplicate wasn't updating links,
so duplicatinvg a objects would still point to the originals for curve-taper, texmesh, drivers.
Use generic id-looper to handle replacing data.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 9fb0cb42dfc..d6b2a3cea29 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -95,6 +95,7 @@ #include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_library_query.h" #include "BKE_linestyle.h" #include "BKE_mesh.h" #include "BKE_material.h" @@ -864,6 +865,31 @@ void *BKE_libblock_copy(ID *id) return BKE_libblock_copy_ex(G.main, id); } +static bool id_relink_looper(void *UNUSED(user_data), ID **id_pointer, const int cd_flag) +{ + ID *id = *id_pointer; + if (id) { + /* See: NEW_ID macro */ + if (id->newid) { + BKE_library_update_ID_link_user(id->newid, id, cd_flag); + *id_pointer = id->newid; + } + else if (id->flag & LIB_NEW) { + id->flag &= ~LIB_NEW; + BKE_libblock_relink(id); + } + } + return true; +} + +void BKE_libblock_relink(ID *id) +{ + if (id->lib) + return; + + BKE_library_foreach_ID_link(id, id_relink_looper, NULL, 0); +} + static void BKE_library_free(Library *lib) { if (lib->packedfile) |