8031696: [macosx] TwentyThousandTest test failed with OOM
authoralexsch
Fri, 28 Nov 2014 19:17:00 +0400
changeset 28077 cdd7ab00a1e2
parent 28076 64c048b63cea
child 28078 3e50120f4b4c
8031696: [macosx] TwentyThousandTest test failed with OOM Reviewed-by: serb, pchelko
jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Fri Nov 28 14:03:56 2014 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Fri Nov 28 19:17:00 2014 +0400
@@ -1300,12 +1300,12 @@
                 filters = (FileFilter[]) e.getNewValue();
                 fireContentsChanged(this, -1, -1);
             } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
-                fireContentsChanged(this, -1, -1);
+                setSelectedItem(e.getNewValue());
             }
         }
 
         public void setSelectedItem(Object filter) {
-            if(filter != null) {
+            if (filter != null && !containsFileFilter(filter)) {
                 getFileChooser().setFileFilter((FileFilter) filter);
                 fireContentsChanged(this, -1, -1);
             }
@@ -1353,6 +1353,10 @@
         }
     }
 
+    private boolean containsFileFilter(Object fileFilter) {
+        return Objects.equals(fileFilter, getFileChooser().getFileFilter());
+    }
+
     /**
      * Acts when FilterComboBox has changed the selected item.
      */
@@ -1363,7 +1367,10 @@
         }
 
         public void actionPerformed(final ActionEvent e) {
-            getFileChooser().setFileFilter((FileFilter) filterComboBox.getSelectedItem());
+            Object selectedFilter = filterComboBox.getSelectedItem();
+            if (!containsFileFilter(selectedFilter)) {
+                getFileChooser().setFileFilter((FileFilter) selectedFilter);
+            }
         }
     }