Fix T61231: File open and undo looses unkeyed changes
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Feb 2019 11:13:02 +0000 (12:13 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Feb 2019 11:17:00 +0000 (12:17 +0100)
Only flush copy-on-write to animation when user makes changes.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/depsgraph.h

index a15e4e7a56f1efc940a38339bc673ff39606a8ef..c62fc604f94b825a4b0402468236fbebac2cd0af 100644 (file)
@@ -2534,11 +2534,23 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
                 *   CoW update when it's changed) but yet guarantee evaluation order
                 *   with objects which are using that action. */
                if (comp_node->type == NodeType::PARAMETERS ||
-                   comp_node->type == NodeType::LAYER_COLLECTIONS ||
-                   (comp_node->type == NodeType::ANIMATION && id_type == ID_AC))
+                   comp_node->type == NodeType::LAYER_COLLECTIONS)
                {
                        rel_flag &= ~RELATION_FLAG_NO_FLUSH;
                }
+               if (comp_node->type == NodeType::ANIMATION && id_type == ID_AC) {
+                       rel_flag &= ~RELATION_FLAG_NO_FLUSH;
+                       /* NOTE: We only allow flush on user edits. If the action block is
+                        * just brought into the dependency graph it is either due to
+                        * initial graph construction or due to some property got animated.
+                        * In first case all the related datablocks will be tagged for an
+                        * update as well. In the second case it is up to the editing
+                        * function to tag changed datablock.
+                        *
+                        * This logic allows to preserve unkeyed changes on file load and on
+                        * undo. */
+                       rel_flag |= RELATION_FLAG_FLUSH_USER_EDIT_ONLY;
+               }
                /* All entry operations of each component should wait for a proper
                 * copy of ID. */
                OperationNode *op_entry = comp_node->get_entry_operation();
index 9a0b01d8679b5c67af927d4b97f077fd83361c08..d33b8945d1722f37e4bb6bfbe76a5da53d2eae91 100644 (file)
@@ -73,9 +73,9 @@ enum RelationFlag {
         * affected by user input. */
        RELATION_FLAG_FLUSH_USER_EDIT_ONLY = (1 << 2),
        /* The relation can not be killed by the cyclic dependencies solver. */
-       RELATION_FLAG_GODMODE              = (1 << 3),
+       RELATION_FLAG_GODMODE              = (1 << 4),
        /* Relation will check existance before being added. */
-       RELATION_CHECK_BEFORE_ADD          = (1 << 4),
+       RELATION_CHECK_BEFORE_ADD          = (1 << 5),
 };
 
 /* B depends on A (A -> B) */