harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r584810 - /harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
Date Mon, 15 Oct 2007 16:04:21 GMT
Author: ayza
Date: Mon Oct 15 09:04:20 2007
New Revision: 584810

URL: http://svn.apache.org/viewvc?rev=584810&view=rev
Log:
Applying patch from HARMONY-4762 ([classlib][swing][html] Flaw in thread synchronization in
BasicTextUI)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java?rev=584810&r1=584809&r2=584810&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
Mon Oct 15 09:04:20 2007
@@ -128,10 +128,6 @@
     // This flag is used in paintSafely, modelToView, viewToModel methods.
     private boolean                isActive             = false;
 
-    // Defined, whether document is instance of AbstractDocument or not.
-    // This flag is calculated only when document is replaced by other.
-    private boolean                isAbstractDocument   = false;
-
     // This flag is used in Listener.InsertUpdate method. It need not to lock
     // document in DocumentListener. Then modelChanged method defines, it need
     // to lock document or not
@@ -283,13 +279,11 @@
             if (StringConstants.TEXT_COMPONENT_DOCUMENT_PROPERTY.equals(name)) {
                 if (document != null) {
                     document.removeDocumentListener(listener);
-                    isAbstractDocument = false;
                 }
                 Object doc = e.getNewValue();
                 if (doc != null) {
                     setDocument((Document)doc);
                     document.addDocumentListener(listener);
-                    isAbstractDocument = (document instanceof AbstractDocument);
                     modelChanged();
                 }
             } else if (StringConstants.COMPONENT_ORIENTATION.equals(name)) {
@@ -724,7 +718,6 @@
             setDocument(component.getDocument());
         }
 
-        isAbstractDocument = (document instanceof AbstractDocument);
         modelChanged();
 
         ((AbstractDocument)component.getDocument())
@@ -757,8 +750,10 @@
      *
      */
     protected void modelChanged() {
+        final Document doc = document;
+
         if (needLock) {
-            readLock();
+            readLock(doc);
         }
         try {
             setDocument(document);
@@ -768,7 +763,7 @@
             setViewSize();
         } finally {
             if (needLock) {
-                readUnlock();
+                readUnlock(doc);
             }
         }
         if (component != null) {
@@ -784,7 +779,9 @@
     public Rectangle modelToView(final JTextComponent comp, final int p,
                                  final Position.Bias b)
             throws BadLocationException {
-        readLock();
+        final Document doc = document;
+    	
+        readLock(doc);
         try {
             Rectangle r = null;
             if (isActive) {
@@ -799,7 +796,7 @@
              }
              return r;
         } finally {
-            readUnlock();
+            readUnlock(doc);
         }
     }
 
@@ -823,7 +820,10 @@
         if (!isActive) {
             return;
         }
-        readLock();
+        
+        final Document doc = document;
+        
+        readLock(doc);
         try {
             Highlighter highlighter = component.getHighlighter();
             Caret caret = component.getCaret();
@@ -840,7 +840,7 @@
             }
             caret.paint(g);
         } finally {
-            readUnlock();
+            readUnlock(doc);
         }
     }
 
@@ -1002,15 +1002,15 @@
         }
     }
 
-    private void readLock() {
-        if (isAbstractDocument) {
-            ((AbstractDocument)document).readLock();
+    private void readLock(final Document doc) {
+        if (doc instanceof AbstractDocument) {
+            ((AbstractDocument)doc).readLock();
         }
     }
 
-    private void readUnlock() {
-        if (isAbstractDocument) {
-            ((AbstractDocument)document).readUnlock();
+    private void readUnlock(final Document doc) {
+        if (doc instanceof AbstractDocument) {
+            ((AbstractDocument)doc).readUnlock();
         }
     }
 



Mime
View raw message