File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
modules/javafx.controls/src
main/java/javafx/scene/control/skin
test/java/test/javafx/scene/control/skin Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ public ChoiceBoxSkin(ChoiceBox<T> control) {
147147 initialize ();
148148
149149 itemsObserver = observable -> updateChoiceBoxItems ();
150- control .itemsProperty ().addListener (new WeakInvalidationListener ( itemsObserver ) );
150+ control .itemsProperty ().addListener (itemsObserver );
151151
152152 control .requestLayout ();
153153 registerChangeListener (control .selectionModelProperty (), e -> updateSelectionModel ());
@@ -206,6 +206,9 @@ public ChoiceBoxSkin(ChoiceBox<T> control) {
206206
207207 /** {@inheritDoc} */
208208 @ Override public void dispose () {
209+ if (getSkinnable () == null ) return ;
210+ // removing itemsObserver fixes NP on setting items
211+ getSkinnable ().itemsProperty ().removeListener (itemsObserver );
209212 // removing the content listener fixes NPE from listener
210213 if (choiceBoxItems != null ) {
211214 choiceBoxItems .removeListener (weakChoiceBoxItemsListener );
Original file line number Diff line number Diff line change @@ -111,10 +111,9 @@ public void testListViewSetItems() {
111111//-------- choiceBox, toolBar
112112
113113 /**
114- * FIXME: Left-over from ChoiceBox fix.
115114 * NPE on sequence setItems -> modify items after skin is replaced.
116115 */
117- @ Test @ Ignore ( "8246202" )
116+ @ Test
118117 public void testChoiceBoxSetItems () {
119118 ChoiceBox <String > box = new ChoiceBox <>();
120119 installDefaultSkin (box );
You can’t perform that action at this time.
0 commit comments