[Bf-blender-cvs] [b3b7319de7a] master: Fix T92224: Refactor of append code unexpectedly changed behavior with 'localize all' off.

Bastien Montagne noreply at git.blender.org
Tue Oct 19 16:26:31 CEST 2021


Commit: b3b7319de7aaa17d96e304857bc57401bb11ad17
Author: Bastien Montagne
Date:   Tue Oct 19 16:08:03 2021 +0200
Branches: master
https://developer.blender.org/rBb3b7319de7aaa17d96e304857bc57401bb11ad17

Fix T92224: Refactor of append code unexpectedly changed behavior with 'localize all' off.

In 2.93 and before, when appending wityh 'localize all' off, all linked
IDs (including indirectly linked ones) from initial library would be
made local.
In 3.0, after refactor from rB3be5ce4aad5e, only directly linked IDs
(i.e. user-selected IDs) would be made local.

This change was not intentional (result of confusing code and naming in
previous implementation), and old behavior is used in some workflows to
control which data is kept linked and which data is made local.

This commit revert to 2.93 behavior.

NOTE: there is still an (extreme) corner case where behavior is
different between 2.93 and 3.0:
If you append (at the same time) object A from LibA.blend, and object B
from LibB.blend, and object B uses somehow a material from LibA.blend:
* In 2.93, that material would have been made local (because it belonged
  to one of the 'initial' libraries, even though not the initial lib of
  object B).
* In 3.0, this material will remain linked, since from object B
  persective it comes from a different library.

===================================================================

M	source/blender/blenloader/BLO_readfile.h
M	source/blender/windowmanager/intern/wm_files_link.c

===================================================================

diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 4656bc64a1f..541483d4eed 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -220,7 +220,9 @@ typedef enum eBLOLibLinkFlags {
   BLO_LIBLINK_NEEDS_ID_TAG_DOIT = 1 << 18,
   /** Set fake user on appended IDs. */
   BLO_LIBLINK_APPEND_SET_FAKEUSER = 1 << 19,
-  /** Append (make local) also indirect dependencies of appended IDs. */
+  /** Append (make local) also indirect dependencies of appended IDs comming from other libraries.
+   * NOTE: All IDs (including indirectly linked ones) coming from the same initial library are
+   * always made local. */
   BLO_LIBLINK_APPEND_RECURSIVE = 1 << 20,
   /** Try to re-use previously appended matching ID on new append. */
   BLO_LIBLINK_APPEND_LOCAL_ID_REUSE = 1 << 21,
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 260ea73cc3b..461ae20cf8a 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -619,6 +619,13 @@ static int foreach_libblock_append_callback(LibraryIDLinkCallbackData *cb_data)
     return IDWALK_RET_NOP;
   }
 
+  const bool do_recursive = (data->lapp_data->flag & BLO_LIBLINK_APPEND_RECURSIVE) != 0;
+  if (!do_recursive && cb_data->id_owner->lib != id->lib) {
+    /* When `do_recursive` is false, we only make local IDs from same library(-ies) as the
+     * initially directly linked ones. */
+    return IDWALK_RET_NOP;
+  }
+
   WMLinkAppendDataItem *item = BLI_ghash_lookup(data->lapp_data->new_id_to_item, id);
   if (item == NULL) {
     item = wm_link_append_data_item_add(data->lapp_data, id->name, GS(id->name), NULL);
@@ -651,7 +658,6 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
 {
   BLI_assert((lapp_data->flag & FILE_LINK) == 0);
 
-  const bool do_recursive = (lapp_data->flag & BLO_LIBLINK_APPEND_RECURSIVE) != 0;
   const bool set_fakeuser = (lapp_data->flag & BLO_LIBLINK_APPEND_SET_FAKEUSER) != 0;
   const bool do_reuse_local_id = (lapp_data->flag & BLO_LIBLINK_APPEND_LOCAL_ID_REUSE) != 0;
 
@@ -723,8 +729,7 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
 
     /* Only check dependencies if we are not keeping linked data, nor re-using existing local data.
      */
-    if (do_recursive &&
-        !ELEM(item->append_action, WM_APPEND_ACT_KEEP_LINKED, WM_APPEND_ACT_REUSE_LOCAL)) {
+    if (!ELEM(item->append_action, WM_APPEND_ACT_KEEP_LINKED, WM_APPEND_ACT_REUSE_LOCAL)) {
       WMLinkAppendDataCallBack cb_data = {
           .lapp_data = lapp_data, .item = item, .reports = reports};
       BKE_library_foreach_ID_link(



More information about the Bf-blender-cvs mailing list