diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-29 18:00:29 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-29 18:00:29 +0300 |
commit | cdc7a24d7b56aed874aefe4d37c6acb1cfcae346 (patch) | |
tree | cf0d5d9b243a39f52179d2deb4855808329cb29c /source/blender/blenkernel/intern/library_query.c | |
parent | 821394937f3da8e3275551e4b1263bb2d84d9471 (diff) |
Fix T48971: Append creates linked image textures if object has shape keys.
Hating all those not-so-real ID types... Here there were two causes for the issue:
1) Linked shapekey ID was made local twice (once from mesh's make local, once by itself).
Solved by not explicitely making shapekeys (nor any other non-linkable datatype) local.
2) Key->from 'back pointer' to its owner was messing 'still in used' detection of linked data
after localization. Fixed with a hack for now, thinking correct solution might actually
be to not consider this pointer at all in libquery ID looper, since it's nothing like
and actual usage of mesh/lattice/curve.
Again, shapekeys as ID is a joke, those should be mere struct, they have absolutely nothing to do in Main, period. :(
Point 2) still demonstrates the need for better handling of IDs dependencies though,
so far we only hit corner cases, but think there could also be valid cases generating those
'dependency cycles' between IDs (ID a using ID b which uses ID a), this will have to be addressed some day...
Diffstat (limited to 'source/blender/blenkernel/intern/library_query.c')
-rw-r--r-- | source/blender/blenkernel/intern/library_query.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 2f83547c14b..86602e6d70a 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -639,6 +639,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u case ID_KE: { + /* XXX Only ID pointer from shapekeys is the 'from' one, which is not actually ID usage. + * Maybe we should even nuke it from here, not 100% sure yet... + * (see also foreach_libblock_id_users_callback). + */ Key *key = (Key *) id; CALLBACK_INVOKE_ID(key->from, IDWALK_NOP); break; @@ -951,10 +955,18 @@ typedef struct IDUsersIter { int count_direct, count_indirect; /* Set by callback. */ } IDUsersIter; -static int foreach_libblock_id_users_callback(void *user_data, ID *UNUSED(self_id), ID **id_p, int cb_flag) +static int foreach_libblock_id_users_callback(void *user_data, ID *self_id, ID **id_p, int cb_flag) { IDUsersIter *iter = user_data; + /* XXX This is actually some kind of hack... + * Issue is, only ID pointer from shapekeys is the 'from' one, which is not actually ID usage. + * Maybe we should even nuke it from BKE_library_foreach_ID_link, not 100% sure yet... + */ + if (GS(self_id->name) == ID_KE) { + return IDWALK_RET_NOP; + } + if (*id_p && (*id_p == iter->id)) { #if 0 printf("%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, indirect_usage: %d)\n", |