Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-09-25 20:09:19 +0300
committerBastien Montagne <bastien@blender.org>2020-09-25 20:11:23 +0300
commit756656caffbadac41b16c69ef7eb3437868c98f0 (patch)
tree3e653a419b478911a9280c7d9a5cbd1d05b33d6e /source/blender/makesrna
parentc6a9b62bb0b139ffe0c06d34150dfbc5de0c4cab (diff)
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.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_rna.c33
1 files changed, 16 insertions, 17 deletions
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,