diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-01-14 18:24:50 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-01-15 13:09:16 +0300 |
commit | f52d315c353f74d395f63c85ccd0a1659e929bd5 (patch) | |
tree | 802df67e29848b2ccbc16cbab43984da9155b342 /source/blender/blenkernel | |
parent | c710ca89332bb392ccff8d6bf0be19255ba16b0c (diff) |
Cleanup: removed disabled 'slow but safer' piece of code in make_local process.
Has been disabled for nearly two years now, think we can safely assume
new, quicker code is working properly now. :)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 53febc34715..0f33fc49ca2 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1930,9 +1930,6 @@ void BKE_library_make_local( TIMEIT_VALUE_PRINT(make_local); #endif - /* Note: Keeping both version of the code (old one being safer, since it still has checks against unused IDs) - * for now, we can remove old one once it has been tested for some time in master... */ -#if 1 /* Step 5: proxy 'remapping' hack. */ for (LinkNode *it = copied_ids; it; it = it->next) { /* Attempt to re-link copied proxy objects. This allows appending of an entire scene @@ -1980,133 +1977,6 @@ void BKE_library_make_local( TIMEIT_VALUE_PRINT(make_local); #endif -#else - LinkNode *linked_loop_candidates = NULL; - - /* Step 5: remove datablocks that have been copied to be localized and are no more used in the end... - * Note that we may have to loop more than once here, to tackle dependencies between linked objects... */ - bool do_loop = true; - while (do_loop) { - do_loop = false; - for (LinkNode *it = copied_ids; it; it = it->next) { - if ((id = it->link) == NULL) { - continue; - } - - bool is_local = false, is_lib = false; - - BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib); - - /* Attempt to re-link copied proxy objects. This allows appending of an entire scene - * from another blend file into this one, even when that blend file contains proxified - * armatures that have local references. Since the proxified object needs to be linked - * (not local), this will only work when the "Localize all" checkbox is disabled. - * TL;DR: this is a dirty hack on top of an already weak feature (proxies). */ - if (GS(id->name) == ID_OB && ((Object *)id)->proxy != NULL) { - Object *ob = (Object *)id; - Object *ob_new = (Object *)id->newid; - - /* Proxies only work when the proxified object is linked-in from a library. */ - if (ob->proxy->id.lib == NULL) { - printf("Warning, proxy object %s will loose its link to %s, because the " - "proxified object is local.\n", id->newid->name, ob->proxy->id.name); - } - /* We can only switch the proxy'ing to a made-local proxy if it is no longer - * referred to from a library. Not checking for local use; if new local proxy - * was not used locally would be a nasty bug! */ - else if (is_local || is_lib) { - printf("Warning, made-local proxy object %s will loose its link to %s, " - "because the linked-in proxy is referenced (is_local=%i, is_lib=%i).\n", - id->newid->name, ob->proxy->id.name, is_local, is_lib); - } - else { - /* we can switch the proxy'ing from the linked-in to the made-local proxy. - * BKE_object_make_proxy() shouldn't be used here, as it allocates memory that - * was already allocated by BKE_object_make_local_ex() (which called BKE_object_copy_ex). */ - ob_new->proxy = ob->proxy; - ob_new->proxy_group = ob->proxy_group; - ob_new->proxy_from = ob->proxy_from; - ob_new->proxy->proxy_from = ob_new; - ob->proxy = ob->proxy_from = ob->proxy_group = NULL; - } - } - - if (!is_local) { - if (!is_lib) { /* Not used at all, we can free it! */ - BLI_assert(!"Unused linked data copy remaining from MakeLibLocal process, should not happen anymore"); - printf("\t%s (from %s)\n", id->name, id->lib->id.name); - BKE_id_free(bmain, id); - it->link = NULL; - do_loop = true; - } - /* Only used by linked data, potential candidate to ugly lib-only dependency cycles... */ - else if ((id->tag & LIB_TAG_DOIT) == 0) { /* Check TAG_DOIT to avoid adding same ID several times... */ - /* Note that we store the node, not directly ID pointer, that way if it->link is set to NULL - * later we can skip it in lib-dependency cycles search later. */ - BLI_linklist_prepend_arena(&linked_loop_candidates, it, linklist_mem); - id->tag |= LIB_TAG_DOIT; - - /* Grrrrrrr... those half-datablocks-stuff... grrrrrrrrrrr... - * Here we have to also tag them as potential candidates, otherwise they would falsy report - * ID they used as 'directly used' in sixth step. */ - ID *ntree = (ID *)ntreeFromID(id); - if (ntree != NULL) { - ntree->tag |= LIB_TAG_DOIT; - } - } - } - } - } - -#ifdef DEBUG_TIME - printf("Step 5: Remove linked datablocks that have been copied and ended fully localized: Done.\n"); - TIMEIT_VALUE_PRINT(make_local); -#endif - - /* Step 6: Try to find circle dependencies between indirectly-linked-only datablocks. - * Those are fake 'usages' that prevent their deletion. See T49775 for nice ugly case. */ - BKE_library_unused_linked_data_set_tag(bmain, false); - for (LinkNode *it = linked_loop_candidates; it; it = it->next) { - if (it->link == NULL) { - continue; - } - if ((id = ((LinkNode *)it->link)->link) == NULL) { - it->link = NULL; - continue; - } - - /* Note: in theory here we are only handling datablocks forming exclusive linked dependency-cycles-based - * archipelagos, so no need to check again after we have deleted one, as done in previous step. */ - if (id->tag & LIB_TAG_DOIT) { - BLI_assert(!"Unused linked data copy remaining from MakeLibLocal process (archipelago case), should not happen anymore"); - /* Object's deletion rely on valid ob->data, but ob->data may have already been freed here... - * Setting it to NULL may not be 100% correct, but should be safe and do the work. */ - if (GS(id->name) == ID_OB) { - ((Object *)id)->data = NULL; - } - - /* Note: *in theory* IDs tagged here are fully *outside* of file scope, totally unused, so we can - * directly wipe them out without caring about clearing their usages. - * However, this is a highly-risky presumption, and nice crasher in case something goes wrong here. - * So for 2.78a will keep the safe option, and switch to more efficient one in master later. */ -#if 1 - BKE_id_free_ex(bmain, id, LIB_ID_FREE_NO_USER_REFCOUNT, false); -#else - BKE_libblock_unlink(bmain, id, false, false); - BKE_id_free(bmain, id); -#endif - ((LinkNode *)it->link)->link = NULL; /* Not strictly necessary, but safer (see T49903)... */ - it->link = NULL; - } - } - -#ifdef DEBUG_TIME - printf("Step 6: Try to find circle dependencies between indirectly-linked-only datablocks: Done.\n"); - TIMEIT_VALUE_PRINT(make_local); -#endif - -#endif - /* This is probably more of a hack than something we should do here, but... * Issue is, the whole copying + remapping done in complex cases above may leave pose channels of armatures * in complete invalid state (more precisely, the bone pointers of the pchans - very crappy cross-datablocks |