changeset 235:df4d263c8015

Backed out 0256de6a4bf6 as it is prone to race conditions.
author Deepak Bhole <dbhole@redhat.com>
date Fri, 27 May 2011 17:03:25 -0400
parents a962e87c78e8
children a28b81cac144
files ChangeLog plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
diffstat 2 files changed, 13 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 27 12:53:15 2011 -0400
+++ b/ChangeLog	Fri May 27 17:03:25 2011 -0400
@@ -1,3 +1,7 @@
+2011-05-27  Deepak Bhole <dbhole@redhat.com>
+
+	* Backed out 0256de6a4bf6
+
 2011-05-27  Omair Majid  <omajid@redhat.com>
 
 	* NEWS: Update.
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Fri May 27 12:53:15 2011 -0400
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Fri May 27 17:03:25 2011 -0400
@@ -1605,26 +1605,15 @@
                 if (cl instanceof JNLPClassLoader.CodeBaseClassLoader)
                     cl = ((JNLPClassLoader.CodeBaseClassLoader) cl).getParentJNLPClassLoader();
 
+                ThreadGroup tg = ((JNLPClassLoader) cl).getApplication().getThreadGroup();
+
                 appletShutdown(p);
                 appletPanels.removeElement(p);
-                
-                /* TODO: Applets don't always shut down nicely. We 
-                 * need to find a proper way to forcibly closing all threads 
-                 * an applet starts during its lifetime 
-                 */
+                dispose();
 
-                try {
-                    SwingUtilities.invokeAndWait(new Runnable() {
-                        public void run() {
-                            dispose();
-                        }
-                    });
-                } catch (Exception e) { // ignore, we are just disposing it
-                }
+                if (tg.activeCount() > 0)
+                    tg.stop();
 
-                // If there are no more applets running, exit the VM
-                // TODO: There is a possible race condition here as count 
-                // can be 0 when an applet is in the initialization phase 
                 if (countApplets() == 0) {
                     appletSystemExit();
                 }
@@ -1635,10 +1624,12 @@
     }
 
     /**
-     * This function should be called to halt the VM when all applets are destroyed.
+     * Exit the program.
+     * Exit from the program (if not stand alone) - do no clean-up
      */
     private void appletSystemExit() {
-        System.exit(0);
+        // Do nothing. Exit is handled by another
+        // block of code, called when _all_ applets are gone
     }
 
     /**