[Bf-blender-cvs] [756656caffb] master: LibOverride: Better handling of cleanup of 'insert' operations in collections.

Bastien Montagne noreply at git.blender.org
Fri Sep 25 19:11:34 CEST 2020


Commit: 756656caffbadac41b16c69ef7eb3437868c98f0
Author: Bastien Montagne
Date:   Fri Sep 25 19:09:19 2020 +0200
Branches: master
https://developer.blender.org/rB756656caffbadac41b16c69ef7eb3437868c98f0

LibOverride: Better handling of cleanup of 'insert' operations in collections.

Before, it might have been possible in some cases (when there were no
items at all anymore in the collection) to miss that cleanup step,
leaving ghost useless and invalid operations around.

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

M	source/blender/makesrna/intern/rna_rna.c

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

diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 8d87de23b3a..a7aa8ccdf71 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -1763,7 +1763,6 @@ int rna_property_override_diff_default(Main *bmain,
     case PROP_COLLECTION: {
       bool equals = true;
       bool abort = false;
-      bool is_first_insert = true;
       int idx_a = 0;
       int idx_b = 0;
 
@@ -1778,6 +1777,22 @@ int rna_property_override_diff_default(Main *bmain,
       char *prev_propname_a = buff_prev_a;
       char *propname_b = NULL;
 
+      if (use_collection_insertion) {
+        /* We need to clean up all possible existing insertion operations, and then re-generate
+         * them, otherwise we'd end up with a mess of opops every time something changes. */
+        op = BKE_lib_override_library_property_find(override, rna_path);
+        if (op != NULL) {
+          LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
+            if (ELEM(opop->operation,
+                     IDOVERRIDE_LIBRARY_OP_INSERT_AFTER,
+                     IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) {
+              BKE_lib_override_library_property_operation_delete(op, opop);
+            }
+          }
+          op = NULL;
+        }
+      }
+
       for (; iter_a.valid && !abort;) {
         bool is_valid_for_diffing;
         bool is_valid_for_insertion;
@@ -1860,22 +1875,6 @@ int rna_property_override_diff_default(Main *bmain,
           if (is_valid_for_insertion && use_collection_insertion) {
             op = BKE_lib_override_library_property_get(override, rna_path, &created);
 
-            if (is_first_insert) {
-              /* We need to clean up all possible existing insertion operations,
-               * otherwise we'd end up with a mess of ops every time something changes. */
-              for (IDOverrideLibraryPropertyOperation *opop = op->operations.first;
-                   opop != NULL;) {
-                IDOverrideLibraryPropertyOperation *opop_next = opop->next;
-                if (ELEM(opop->operation,
-                         IDOVERRIDE_LIBRARY_OP_INSERT_AFTER,
-                         IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) {
-                  BKE_lib_override_library_property_operation_delete(op, opop);
-                }
-                opop = opop_next;
-              }
-              is_first_insert = false;
-            }
-
             BKE_lib_override_library_property_operation_get(op,
                                                             IDOVERRIDE_LIBRARY_OP_INSERT_AFTER,
                                                             NULL,



More information about the Bf-blender-cvs mailing list