[Bf-blender-cvs] [a6b6f5db10a] master: Fix issue with recent refactor in liboverride diffing.

Bastien Montagne noreply at git.blender.org
Wed Jan 11 15:32:10 CET 2023


Commit: a6b6f5db10aebcc13c7e42134c5f2dd66b030b20
Author: Bastien Montagne
Date:   Wed Jan 11 15:27:31 2023 +0100
Branches: master
https://developer.blender.org/rBa6b6f5db10aebcc13c7e42134c5f2dd66b030b20

Fix issue with recent refactor in liboverride diffing.

New code from rBd05909a70c36 last week did not take into account
liboverride templates and `NOOP` operations. So we cannot assume that
there is no valid override property for these which need to be restored.

While we may get rid of templates at some point now, for now they are
still exposed in PY API, and have some basic unittests, so keep them
working as best as possible.

Issue reported on IRC by Martijn Versteegh (@Baardaap), thanks!

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

M	source/blender/blenkernel/intern/lib_override.cc
M	source/blender/makesrna/intern/rna_access_compare_override.c

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

diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index 0cbed770ed1..8a9440a8e32 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -3394,7 +3394,18 @@ void BKE_lib_override_library_operations_restore(Main *bmain, ID *local, int *r_
   LISTBASE_FOREACH_MUTABLE (
       IDOverrideLibraryProperty *, op, &local->override_library->properties) {
     if (op->tag & IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) {
-      BKE_lib_override_library_property_delete(local->override_library, op);
+      LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
+        if (opop->tag & IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) {
+          BKE_lib_override_library_property_operation_delete(op, opop);
+        }
+      }
+      if (BLI_listbase_is_empty(&local->override_library->properties)) {
+        BKE_lib_override_library_property_delete(local->override_library, op);
+      }
+      else {
+        BKE_lib_override_library_operations_tag(
+            op, IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE, false);
+      }
     }
   }
   local->override_library->runtime->tag &= ~IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE;
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index a0a084869d8..af13171f202 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -821,8 +821,6 @@ bool RNA_struct_override_matches(Main *bmain,
             /* This property should be restored to its reference value. This should not be done
              * here, since this code may be called from non-main thread (modifying data through RNA
              * is not thread safe). */
-            BLI_assert(op == NULL); /* Forbidden override prop should not exist currently. */
-
             if (do_restore) {
               IDOverrideLibraryPropertyOperation opop_tmp = {
                   .operation = IDOVERRIDE_LIBRARY_OP_REPLACE,
@@ -850,10 +848,14 @@ bool RNA_struct_override_matches(Main *bmain,
                 op = BKE_lib_override_library_property_get(override, rna_path, NULL);
                 BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, true);
               }
-              BKE_lib_override_library_property_operation_get(
-                  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, false, NULL, NULL);
-              BKE_lib_override_library_operations_tag(
-                  op, IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE, true);
+              IDOverrideLibraryPropertyOperation *opop_restore =
+                  BKE_lib_override_library_property_operation_get(
+                      op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, false, NULL, NULL);
+              /* Do not use `BKE_lib_override_library_operations_tag` here, as the property may be
+               * a valid one that has other operations that needs to remain (e.g. from a template,
+               * a NOOP operation to enforce no change on that property, etc.). */
+              op->tag |= IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE;
+              opop_restore->tag |= IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE;
               override->runtime->tag |= IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE;
 
               if (r_report_flags) {
@@ -1153,6 +1155,10 @@ static void rna_property_override_apply_ex(Main *bmain,
                                            const bool do_insert)
 {
   LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
+    if (opop->operation == IDOVERRIDE_LIBRARY_OP_NOOP) {
+      continue;
+    }
+
     if (!do_insert != !ELEM(opop->operation,
                             IDOVERRIDE_LIBRARY_OP_INSERT_AFTER,
                             IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) {



More information about the Bf-blender-cvs mailing list