harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r585975 - in /harmony/enhanced/classlib/trunk/modules: awt/src/main/java/common/java/awt/ swing/src/main/java/common/javax/swing/ swing/src/main/java/common/org/apache/harmony/x/swing/
Date Thu, 18 Oct 2007 14:30:48 GMT
Author: apetrenko
Date: Thu Oct 18 07:30:47 2007
New Revision: 585975

URL: http://svn.apache.org/viewvc?rev=585975&view=rev
Log:
Patch for HARMONY-4925 "[classlib][awt] GDI Objects are not released 
after calling getGraphics() function of Component class"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Frame.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/PopupBox.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/BlitSupport.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
Thu Oct 18 07:30:47 2007
@@ -572,8 +572,8 @@
         FontMetrics fm = getFontMetrics(font);
         minSize.height = fm.getHeight() + vGap + 1;
         minSize.width = hGap + 16; // TODO: use arrow button size
-
-        FontRenderContext frc = ((Graphics2D) getGraphics()).getFontRenderContext();
+        Graphics2D gr = (Graphics2D) getGraphics();
+        FontRenderContext frc = gr.getFontRenderContext();
         int maxItemWidth = 5; // TODO: take width of some char
         for (int i = 0; i < items.size(); i++) {
             String item = getItem(i);
@@ -583,6 +583,7 @@
             }
         }
         minSize.width += maxItemWidth;
+        gr.dispose();
         return minSize;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Frame.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Frame.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Frame.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Frame.java Thu
Oct 18 07:30:47 2007
@@ -572,6 +572,7 @@
             if (g != null) {
                 menuBar.paint(g);
             }
+            g.dispose();
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java Thu
Oct 18 07:30:47 2007
@@ -874,12 +874,14 @@
             if (!isDisplayable()) {
                 return new Dimension();
             }
-            Dimension charSize = getMaxCharSize(getGraphics());
+            Graphics gr = getGraphics();
+            Dimension charSize = getMaxCharSize(gr);
             int minRowHeight = charSize.height + 1;
             final int MIN_CHARS_IN_ROW = 12;
             int hGap = 2 * BORDER_SIZE;
             int vGap = hGap;
             int minWidth = charSize.width * MIN_CHARS_IN_ROW + hGap;
+            gr.dispose();
             return new Dimension(minWidth, rows * minRowHeight + vGap);
         } finally {
             toolkit.unlockAWT();
@@ -897,7 +899,8 @@
                 return new Dimension();
             }
             int maxItemWidth = minSize.width;
-            FontRenderContext frc = ((Graphics2D) getGraphics()).getFontRenderContext();
+            Graphics2D gr = (Graphics2D) getGraphics();
+            FontRenderContext frc = gr.getFontRenderContext();
             Font font = getFont();
             for (int i = 0; i < items.size(); i++) {
                 String item = getItem(i);
@@ -906,6 +909,7 @@
                     maxItemWidth = itemWidth;
                 }
             }
+            gr.dispose();
             return new Dimension(maxItemWidth, minSize.height);
         } finally {
             toolkit.unlockAWT();
@@ -1499,8 +1503,10 @@
         Dimension clientSize = getClient().getSize();
         vAdjustable.setUnitIncrement(itemSize.height);
         vAdjustable.setBlockIncrement(clientSize.height);
-        hAdjustable.setUnitIncrement(getMaxCharSize(getGraphics()).width);
+        Graphics gr = getGraphics();
+        hAdjustable.setUnitIncrement(getMaxCharSize(gr).width);
         hAdjustable.setBlockIncrement(clientSize.width);
+        gr.dispose();
     }
 
     private boolean isIdxValid(int index) {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java
Thu Oct 18 07:30:47 2007
@@ -670,6 +670,7 @@
         if (gr != null) {
             paint(gr);
         }
+        gr.dispose();
         if (showSubMenu) {
             showSubMenu(selectedItemIndex);
         }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/PopupBox.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/PopupBox.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/PopupBox.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/PopupBox.java
Thu Oct 18 07:30:47 2007
@@ -142,6 +142,7 @@
             if (gr != null) {
                 paint(gr);
             }
+            gr.dispose();
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
Thu Oct 18 07:30:47 2007
@@ -112,6 +112,7 @@
             }         
             g.drawRect(0, 0, 40, 40);
             paint(g);
+            g.dispose();
         }                
         public abstract void paint(Graphics g);
     }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java
Thu Oct 18 07:30:47 2007
@@ -1034,6 +1034,7 @@
             repaintRegion.convertRegion(this, effectiveRoot);
             repaintRegion.intersect(visibleRect);
             if (repaintRegion.isEmpty()) {
+                g.dispose();
                 return;
             }
             if (g instanceof Graphics2D) {
@@ -1046,6 +1047,7 @@
             repaintRect = SwingUtilities.computeIntersection(repaintRect.x, repaintRect.y,
                     repaintRect.width, repaintRect.height, visibleRect);
             if (repaintRect.isEmpty()) {
+                g.dispose();
                 return;
             }
             g.clipRect(rect.x, rect.y, rect.width, rect.height);
@@ -1057,6 +1059,7 @@
         } else {
             effectiveRoot.paint(g);
         }
+        g.dispose();
     }
 
     public void paintImmediately(int x, int y, int width, int height) {
@@ -1426,6 +1429,7 @@
             g.drawImage(image, clipRect.x, clipRect.y, this);
         } finally {
             doubleBufferingRoot = false;
+            offscreenGraphics.dispose();
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/BlitSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/BlitSupport.java?rev=585975&r1=585974&r2=585975&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/BlitSupport.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/BlitSupport.java
Thu Oct 18 07:30:47 2007
@@ -140,6 +140,7 @@
         if (!wasPainted) {
             onPaint();
         }
+        g.dispose();
 
         return true;
     }



Mime
View raw message