Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8303680: Virtual Flow freezes after calling scrollTo and scrollPixels…
… in succession

Reviewed-by: angorya, jvos
  • Loading branch information
FlorianKirmaier authored and Andy Goryachev committed Mar 16, 2023
1 parent 935c7b7 commit 6be8703
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Expand Up @@ -1715,7 +1715,6 @@ public double scrollPixels(final double delta) {

// Finally, update the scroll bars
updateScrollBarsAndCells(false);
lastPosition = getPosition();

// notify
return answer;
Expand Down
Expand Up @@ -2518,4 +2518,46 @@ public static void verifyListViewScrollTo(ListView listView, int listViewHeight,

}

@Test
public void fixListViewCrash_JDK_8303680() {
final ListView<String> listView = new ListView<>();

// add 100 entries
listView.setPrefSize(200, 200);
for (int i = 0; i < 100; i++) {
listView.getItems().add("Item " + i);
}
StageLoader sl = new StageLoader(new VBox(listView, new Button()));

// pulse
Toolkit.getToolkit().firePulse();

// get virtual flow
VirtualFlow vf = VirtualFlowTestUtils.getVirtualFlow(listView);

// scroll to 50 and scroll 1 pixel
vf.scrollTo(50);
vf.scrollPixels(1);

// another pulse
Toolkit.getToolkit().firePulse();

// scroll to cell
IndexedCell<Integer> cell = vf.getCell(50);//VirtualFlowTestUtils.getCell(listView, 70);

// shouldn't be null
assertNotNull(cell);

// should be visible
assertTrue("Cell should be visible", cell.isVisible());

// should have parent
assertNotNull("Cell should have parent", cell.getParent());

// Note:
// We don't check for the position of the cell, because it's currently don't work properly.
// But we wan't to ensure, that the VirtualFlow "Doesn't crash" - which was the case before.

}

}

1 comment on commit 6be8703

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.