[Bf-blender-cvs] [5225e459da0] master: Fix T86883: Add/fix suport of liboverrides in relocate/reload library case.

Bastien Montagne noreply at git.blender.org
Fri Aug 13 16:38:59 CEST 2021


Commit: 5225e459da07b10b5d1a77f74fed2d3df1fee594
Author: Bastien Montagne
Date:   Fri Aug 13 16:34:06 2021 +0200
Branches: master
https://developer.blender.org/rB5225e459da07b10b5d1a77f74fed2d3df1fee594

Fix T86883: Add/fix suport of liboverrides in relocate/reload library case.

There was already some code for that, but it was broken, and proper
resync was completely missing.

There might still be more resync needed in library linking operators
though.

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

M	source/blender/windowmanager/intern/wm_files_link.c

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

diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 7c3fce7fcb2..cdcb6c5163f 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -831,7 +831,7 @@ static void lib_relocate_do_remap(Main *bmain,
   }
 }
 
-static void lib_relocate_do(Main *bmain,
+static void lib_relocate_do(bContext *C,
                             Library *library,
                             WMLinkAppendData *lapp_data,
                             ReportList *reports,
@@ -843,6 +843,10 @@ static void lib_relocate_do(Main *bmain,
   LinkNode *itemlink;
   int item_idx;
 
+  Main *bmain = CTX_data_main(C);
+  Scene *scene = CTX_data_scene(C);
+  ViewLayer *view_layer = CTX_data_view_layer(C);
+
   /* Remove all IDs to be reloaded from Main. */
   lba_idx = set_listbasepointers(bmain, lbarray);
   while (lba_idx--) {
@@ -990,21 +994,31 @@ static void lib_relocate_do(Main *bmain,
     }
   }
 
-  /* Update overrides of reloaded linked data-blocks.
-   * Note that this will not necessarily fully update the override, it might need to be manually
-   * 're-generated' depending on changes in linked data. */
+  /* Update overrides of reloaded linked data-blocks. */
   ID *id;
   FOREACH_MAIN_ID_BEGIN (bmain, id) {
     if (ID_IS_LINKED(id) || !ID_IS_OVERRIDE_LIBRARY_REAL(id) ||
         (id->tag & LIB_TAG_PRE_EXISTING) == 0) {
       continue;
     }
-    if (id->override_library->reference->lib == library) {
+    if ((id->override_library->reference->tag & LIB_TAG_PRE_EXISTING) == 0) {
       BKE_lib_override_library_update(bmain, id);
     }
   }
   FOREACH_MAIN_ID_END;
 
+  /* Resync overrides if needed. */
+  if (!USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) {
+    BKE_lib_override_library_main_resync(bmain,
+                                         scene,
+                                         view_layer,
+                                         &(struct BlendFileReadReport){
+                                             .reports = reports,
+                                         });
+    /* We need to rebuild some of the deleted override rules (for UI feedback purpose). */
+    BKE_lib_override_library_main_operations_create(bmain, true);
+  }
+
   BKE_main_collection_sync(bmain);
 
   BKE_main_lib_objects_recalc_all(bmain);
@@ -1039,7 +1053,7 @@ void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
 
   wm_link_append_data_library_add(lapp_data, lib->filepath_abs);
 
-  lib_relocate_do(CTX_data_main(C), lib, lapp_data, reports, true);
+  lib_relocate_do(C, lib, lapp_data, reports, true);
 
   wm_link_append_data_free(lapp_data);
 
@@ -1162,7 +1176,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
       lapp_data->flag |= BLO_LIBLINK_USE_PLACEHOLDERS | BLO_LIBLINK_FORCE_INDIRECT;
     }
 
-    lib_relocate_do(bmain, lib, lapp_data, op->reports, do_reload);
+    lib_relocate_do(C, lib, lapp_data, op->reports, do_reload);
 
     wm_link_append_data_free(lapp_data);



More information about the Bf-blender-cvs mailing list