/hg/icedtea-web: Fix undisposed window problem. It was causing A...

dlila at icedtea.classpath.org dlila at icedtea.classpath.org
Fri Jun 10 10:16:13 PDT 2011


changeset 6b46e55a8854 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=6b46e55a8854
author: Denis Lila <dlila at redhat.com>
date: Fri Jun 10 13:13:02 2011 -0400

	Fix undisposed window problem. It was causing AWT to never shut
	down.


diffstat:

 ChangeLog                                                     |   9 +
 netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java |  66 ++++++----
 2 files changed, 47 insertions(+), 28 deletions(-)

diffs (115 lines):

diff -r 6ffc4d00a43f -r 6b46e55a8854 ChangeLog
--- a/ChangeLog	Thu Jun 09 17:11:34 2011 -0400
+++ b/ChangeLog	Fri Jun 10 13:13:02 2011 -0400
@@ -1,3 +1,12 @@
+2011-06-10  Denis Lila  <dlila at redhat.com>
+
+	* netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java:
+	(frameMutex): New mutex to synchronize accesses to "frame".
+	(getListener): Make almost all of it synchronized on frameMutex.
+	(disposeListener): Sync hider's body around frameMutex and call
+	dispose on the frame so that the awt threads die when they should.
+	(addProgressPanel): Sync "frame" usage.
+
 2011-06-08  Saad Mohammad  <smohammad at redhat.com>
 
 	* AUTHORS: Updated
diff -r 6ffc4d00a43f -r 6b46e55a8854 netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java	Thu Jun 09 17:11:34 2011 -0400
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java	Fri Jun 10 13:13:02 2011 -0400
@@ -57,6 +57,7 @@
 
     /** the display window */
     private static JFrame frame;
+    private static final Object frameMutex = new Object();
 
     /** shared constraint */
     static GridBagConstraints vertical;
@@ -97,30 +98,32 @@
     public DownloadServiceListener getListener(ApplicationInstance app, String downloadName, URL resources[]) {
         DownloadPanel result = new DownloadPanel(downloadName);
 
-        if (frame == null) {
-            frame = new JFrame(downloading + "...");
-            frame.getContentPane().setLayout(new GridBagLayout());
+        synchronized (frameMutex) {
+            if (frame == null) {
+                frame = new JFrame(downloading + "...");
+                frame.getContentPane().setLayout(new GridBagLayout());
+            }
+
+            if (resources != null)
+                for (int i = 0; i < resources.length; i++)
+                    result.addProgressPanel(resources[i], null);
+
+            frame.getContentPane().add(result, vertical);
+            frame.pack();
+
+            if (!frame.isVisible()) {
+                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+                Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
+                Dimension screen = new Dimension(screenSize.width - insets.left,
+                        screenSize.height - insets.top);
+                frame.setLocation(screen.width - frame.getWidth(),
+                        screen.height - frame.getHeight());
+            }
+
+            frame.setVisible(true);
+
+            return result;
         }
-
-        if (resources != null)
-            for (int i = 0; i < resources.length; i++)
-                result.addProgressPanel(resources[i], null);
-
-        frame.getContentPane().add(result, vertical);
-        frame.pack();
-
-        if (!frame.isVisible()) {
-            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-            Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
-            Dimension screen = new Dimension(screenSize.width - insets.left,
-                    screenSize.height - insets.top);
-            frame.setLocation(screen.width - frame.getWidth(),
-                              screen.height - frame.getHeight());
-        }
-
-        frame.setVisible(true);
-
-        return result;
     }
 
     /**
@@ -134,11 +137,16 @@
 
         ActionListener hider = new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
-                if (frame.getContentPane().getComponentCount() == 1)
-                    frame.setVisible(false);
+                synchronized(frameMutex) {
+                    frame.getContentPane().remove((DownloadPanel) listener);
+                    frame.pack();
 
-                frame.getContentPane().remove((DownloadPanel) listener);
-                frame.pack();
+                    if (frame.getContentPane().getComponentCount() == 0) {
+                        frame.setVisible(false);
+                        frame.dispose();
+                        frame = null;
+                    }
+                }
             }
         };
 
@@ -186,7 +194,9 @@
                 ProgressPanel panel = new ProgressPanel(url, version);
 
                 add(panel, verticalIndent);
-                frame.pack();
+                synchronized (frameMutex) {
+                    frame.pack();
+                }
 
                 urls.add(url);
                 panels.add(panel);



More information about the distro-pkg-dev mailing list