Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8200206

Adding an animation to more than one parent results in inconsistent state

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, 9, 10, openjfx11
    • Fix Version/s: openjfx16
    • Component/s: javafx
    • Labels:
      None

      Description

      Parallel and Sequential transitions can have child animations. An animation can be added to more than one parent and all parents will have the child animation in their children list, but the animation's data structure can only hold one parent. This causes the following inconsistencies:

      1. Adding an animation to 2 parents causes it to only treat the second parent as a parent.
      2. Adding an animation to 2 parents, then removing it from one parent, causes it to have no parent.

      If multiple parents is an intended state, the data structure needs to reflect this, and the public API method Transition#getParentTargetNode() needs to be updated.
      The first solution that comes to mind is to hold a set of parents instead of a single one.

      If multiple parents is not an intended state, adding an animation to a parent must remove the animation from the previous parent.

      The following test code demonstrates the problem:

              Animation child = new PauseTransition();
              SequentialTransition parent1 = new SequentialTransition();
              ParallelTransition parent2 = new ParallelTransition();
              assertEquals("Animation should have no parent", null, AnimationShim.getParent(child));

              parent1.getChildren().add(child);
              assertTrue(parent1.getChildren().contains(child));
              assertEquals("Animation should have a SequentialTransition parent", parent1, AnimationShim.getParent(child));

              parent2.getChildren().add(child);
              assertTrue(parent1.getChildren().contains(child));
              assertTrue(parent2.getChildren().contains(child));
              assertEquals("Animation should still have a SequentialTransition parent", parent1, AnimationShim.getParent(child)); // fails

              parent2.getChildren().remove(child);
              assertTrue(parent1.getChildren().contains(child));
              assertTrue(!parent2.getChildren().contains(child));
              assertEquals("Animation should still have a SequentialTransition parent", parent1, AnimationShim.getParent(child)); // fails

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                nlisker Nir Lisker
                Reporter:
                nlisker Nir Lisker
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: