Commit: cdc7a24d7b56aed874aefe4d37c6acb1cfcae346
Author: Bastien Montagne
Date: Fri Jul 29 17:00:29 2016 +0200
Branches: master
https://developer.blender.org/rBcdc7a24d7b56aed874aefe4d37c6acb1cfcae346
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...
===================================================================
M source/blender/blenkernel/intern/library.c
M source/blender/blenkernel/intern/library_query.c
===================================================================
diff --git a/source/blender/blenkernel/intern/library.c
b/source/blender/blenkernel/intern/library.c
index eb0aec9..5a63991 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 2f83547..86602e6 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",
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs