changeset 289:025dacc36e76

Fixing index out of bounds exception introduced in the fix for RT-18972.
author jgiles
date Fri, 20 Jan 2012 17:15:25 +1300
parents e5e4e7faf0cf
children c1cc0e7893d3
files javafx-ui-controls/src/javafx/scene/control/ListView.java
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/ListView.java	Fri Jan 20 13:55:49 2012 +1300
+++ b/javafx-ui-controls/src/javafx/scene/control/ListView.java	Fri Jan 20 17:15:25 2012 +1300
@@ -978,10 +978,10 @@
             while (c.next()) {
                 if (c.wasReplaced()) {
                     // Fix for RT-18969: the list had setAll called on it
-                    if (getSelectedIndex() < getItemCount()) {
-                        int selectedIndex = getSelectedIndex();
-                        clearSelection(selectedIndex);
-                        select(selectedIndex);
+                    int index = getSelectedIndex();
+                    if (index < getItemCount() && index >= 0) {
+                        clearSelection(index);
+                        select(index);
                     }
                 } else if (c.wasAdded() || c.wasRemoved()) {
                     int shift = c.wasAdded() ? c.getAddedSize() : -c.getRemovedSize();