Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-07-29 18:00:29 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-07-29 18:00:29 +0300
commitcdc7a24d7b56aed874aefe4d37c6acb1cfcae346 (patch)
treecf0d5d9b243a39f52179d2deb4855808329cb29c
parent821394937f3da8e3275551e4b1263bb2d84d9471 (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...
-rw-r--r--source/blender/blenkernel/intern/library.c11
-rw-r--r--source/blender/blenkernel/intern/library_query.c14
2 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index eb0aec90cf9..5a6399145fa 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -320,7 +320,6 @@ void BKE_id_make_local_generic(Main *bmain, ID *id, const bool id_in_mainlist, c
}
}
}
-
}
/**
@@ -1634,7 +1633,15 @@ void BKE_library_make_local(Main *bmain, const Library *lib, const bool untagged
int a;
for (a = set_listbasepointers(bmain, lbarray); a--; ) {
- for (id = lbarray[a]->first; id; id = id_next) {
+ id = lbarray[a]->first;
+
+ if (!id || !BKE_idcode_is_linkable(GS(id->name))) {
+ /* Do not explicitely make local non-linkable IDs (shapekeys, in fact), they are assumed to be handled
+ * by real datablocks responsible of them. */
+ continue;
+ }
+
+ for (; id; id = id_next) {
id->newid = NULL;
id_next = id->next; /* id is possibly being inserted again */
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",