harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r465985 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/ test/api/java/common/javax/swing/plaf/basic/ test/api/java/common/javax/swing/text/
Date Fri, 20 Oct 2006 04:34:42 GMT
Author: mloenko
Date: Thu Oct 19 21:34:41 2006
New Revision: 465985

URL: http://svn.apache.org/viewvc?view=rev&rev=465985
Log:
applied patch from HARMONY-1475
[classlib][swing/text] Editing text in JTextComponent after updateUI() throws NPE

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUIRTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentRTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java?view=diff&rev=465985&r1=465984&r2=465985
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
Thu Oct 19 21:34:41 2006
@@ -929,6 +929,9 @@
         uninstallDefaults();
         uninstallKeyboardActions();
         uninstallListeners();
+        ((AbstractDocument) component.getDocument())
+                .removeDocumentListener(listener);
+        component.removePropertyChangeListener(listener);
 
         //DnD support
         //java.awt.Component doesn't support DnD

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUIRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUIRTest.java?view=diff&rev=465985&r1=465984&r2=465985
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUIRTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUIRTest.java
Thu Oct 19 21:34:41 2006
@@ -29,6 +29,7 @@
 import javax.swing.JTextField;
 import javax.swing.KeyStroke;
 import javax.swing.SwingTestCase;
+import javax.swing.text.AbstractDocument;
 import javax.swing.text.JTextComponent;
 
 public class BasicTextUIRTest extends SwingTestCase {
@@ -115,6 +116,17 @@
         textComp.setEditable(true);
         checkNotEditableFTK(textComp);
 
+    }
+    
+    public void testUninstallUI() {
+        // Regression for HARMONY-1475
+        JTextComponent textComp = new JTextField();
+        AbstractDocument doc = ((AbstractDocument) textComp.getDocument());
+        assertTrue("listeners installed", 
+                   doc.getDocumentListeners().length > 0);
+        textComp.getUI().uninstallUI(textComp);
+        assertEquals("no listeners installed", 0,
+                     doc.getDocumentListeners().length);
     }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentRTest.java?view=diff&rev=465985&r1=465984&r2=465985
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentRTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/JTextComponentRTest.java
Thu Oct 19 21:34:41 2006
@@ -25,6 +25,16 @@
 import junit.framework.TestCase;
 
 public class JTextComponentRTest extends TestCase {
+    
+    class JMyTextComponent extends JTextComponent {
+        public String getUIClassID() {
+            return "TextFieldUI";
+        }
+
+        public void test(final KeyEvent event) {
+            processKeyEvent(event);
+        }
+    };
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -35,18 +45,17 @@
     }
 
     public void testProcessKeyEvent() {
-        class JMyTextComponent extends JTextComponent {
-            public String getUIClassID() {
-                return "TextFieldUI";
-            }
-
-            public void test(final KeyEvent event) {
-                processKeyEvent(event);
-            }
-        };
         JMyTextComponent c = new JMyTextComponent();
         KeyEvent event = new KeyEvent(c, KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED,
'\n');
         c.setKeymap(null);
         c.test(event);
+    }
+    
+    public void testUpdateUI() {
+        // regression test for HARMONY-1475
+        JMyTextComponent c = new JMyTextComponent();
+        c.updateUI();
+        c.setText("q");
+        assertEquals("q", c.getText());
     }
 }



Mime
View raw message