Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CodenameOne/src/com/codename1/ui/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -4299,8 +4299,6 @@ public MorphAnimation(Container thisContainer, int duration, Motion[][] motions)
}
this.thisContainer = thisContainer;
this.motions = motions;
animatedComponents = new Vector();
opacity = new Motion[0];
}

@Override
Expand Down Expand Up @@ -4331,7 +4329,7 @@ protected void updateState() {
currentCmp.setY(motions[1][iter].getValue());
currentCmp.setWidth(motions[2][iter].getValue());
currentCmp.setHeight(motions[3][iter].getValue());
if (opacity != null) {
if (opacity != null && iter < opacity.length) {
currentCmp.getStyle().setOpacity(opacity[iter].getValue(), false);
}
}
Expand All @@ -4351,7 +4349,7 @@ protected void updateState() {
currentCmp.setY(motions[1][iter].getValue());
currentCmp.setWidth(motions[2][iter].getValue());
currentCmp.setHeight(motions[3][iter].getValue());
if (opacity != null) {
if (opacity != null && iter < opacity.length) {
currentCmp.getStyle().setOpacity(opacity[iter].getValue(), false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ void testMorphAnimation() {
assertEquals(c.getBounds(), a.getBounds());
}

@FormTest
void testAnimateHierarchyWithDefaultOpacityDoesNotCrash() {
Form form = CN.getCurrentForm();
form.removeAll();
form.setLayout(BoxLayout.y());

Label first = new Label("First");
Label second = new Label("Second");
form.addAll(first, second);
form.revalidate();

// Regression guard for commit 4e5cbc2c2092721c8861a34d557fe56fe742e82b where
// MorphAnimation's constructor began initializing opacity to an empty array.
// When animateHierarchy() is invoked without fade (the default, matching
// Form.animateHierarchy and Codename One 7.0.208), MorphAnimation.opacity
// remains zero-length yet non-null. The flush() call below mirrors Display.flushEdt()
// from the stack trace and would previously trigger an ArrayIndexOutOfBoundsException.
assertDoesNotThrow(() -> {
form.animateHierarchy(100);
form.getAnimationManager().flush();
});
}

@Test
void testScrollableFlagsRespectBorderLayout() {
Container container = new Container(new BorderLayout());
Expand Down
Loading