-
Bug
-
Resolution: Fixed
-
P4
-
jfx14
title says it all :) Once a skin has been attached to the control, replacing the control's selectionModel keeps a reference to the old selectionModel's selectedItem.
the offending lines in TabPaneSkin constructor (commenting them will let the test pass):
registerChangeListener(control.getSelectionModel().selectedItemProperty(), e -> {
isSelectingTab = true;
selectedTab = getSkinnable().getSelectionModel().getSelectedItem();
getSkinnable().requestLayout();
});
Failing test case (in SelectionFocusModelTest that's added in the fix forJDK-8241455, this method effectively ignored until this is fixed)
@Test
public void testTabPaneSelectionModel() {
TabPane control = new TabPane();
ObservableList<String> data = FXCollections.observableArrayList("Apple", "Orange", "Banana");
data.forEach(text -> control.getTabs().add(new Tab("text")));
WeakReference<SelectionModel<?>> weakRef = new WeakReference<>(control.getSelectionModel());
SingleSelectionModel<Tab> replacingSm = TabPaneShim.getTabPaneSelectionModel(control);
showControl(control);
control.setSelectionModel(replacingSm);
attemptGC(weakRef, 10);
assertNull("selectionModel must be gc'ed", weakRef.get());
}
the offending lines in TabPaneSkin constructor (commenting them will let the test pass):
registerChangeListener(control.getSelectionModel().selectedItemProperty(), e -> {
isSelectingTab = true;
selectedTab = getSkinnable().getSelectionModel().getSelectedItem();
getSkinnable().requestLayout();
});
Failing test case (in SelectionFocusModelTest that's added in the fix for
@Test
public void testTabPaneSelectionModel() {
TabPane control = new TabPane();
ObservableList<String> data = FXCollections.observableArrayList("Apple", "Orange", "Banana");
data.forEach(text -> control.getTabs().add(new Tab("text")));
WeakReference<SelectionModel<?>> weakRef = new WeakReference<>(control.getSelectionModel());
SingleSelectionModel<Tab> replacingSm = TabPaneShim.getTabPaneSelectionModel(control);
showControl(control);
control.setSelectionModel(replacingSm);
attemptGC(weakRef, 10);
assertNull("selectionModel must be gc'ed", weakRef.get());
}
- relates to
-
JDK-8241455 Memory leak on replacing selection/focusModel
- Resolved