/hg/release/icedtea-web-1.1: Prevent applet from shutting down d...

dbhole at icedtea.classpath.org dbhole at icedtea.classpath.org
Mon May 2 12:33:38 PDT 2011


changeset 0256de6a4bf6 in /hg/release/icedtea-web-1.1
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.1?cmd=changeset;node=0256de6a4bf6
author: Deepak Bhole <dbhole at redhat.com>
date: Mon May 02 14:33:32 2011 -0400

	Prevent applet from shutting down down if another tab with the same
	page is opened and closed.


diffstat:

 ChangeLog                                                |   8 ++++
 plugin/icedteanp/java/sun/applet/PluginAppletViewer.java |  27 ++++++++++-----
 2 files changed, 26 insertions(+), 9 deletions(-)

diffs (65 lines):

diff -r a0a061a0560d -r 0256de6a4bf6 ChangeLog
--- a/ChangeLog	Thu Apr 28 16:23:11 2011 -0400
+++ b/ChangeLog	Mon May 02 14:33:32 2011 -0400
@@ -1,3 +1,11 @@
+2011-05-02  Deepak Bhole <dbhole at redhat.com>
+
+	* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+	(appletClose): Do not try to stop threads, now that the loader is shared
+	and the thread group for applets on a page is identical. Call dispose from
+	invokeAndWait.
+	(appletSystemExit): Exit the VM when called.
+
 2011-04-28  Omair Majid  <omajid at redhat.com>
 
 	* Makefile.am (javaws, itweb_settings): New variables.
diff -r a0a061a0560d -r 0256de6a4bf6 plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Thu Apr 28 16:23:11 2011 -0400
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Mon May 02 14:33:32 2011 -0400
@@ -1605,15 +1605,26 @@
                 if (cl instanceof JNLPClassLoader.CodeBaseClassLoader)
                     cl = ((JNLPClassLoader.CodeBaseClassLoader) cl).getParentJNLPClassLoader();
 
-                ThreadGroup tg = ((JNLPClassLoader) cl).getApplication().getThreadGroup();
-
                 appletShutdown(p);
                 appletPanels.removeElement(p);
-                dispose();
+                
+                /* 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 
+                 */
 
-                if (tg.activeCount() > 0)
-                    tg.stop();
+                try {
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        public void run() {
+                            dispose();
+                        }
+                    });
+                } catch (Exception e) { // ignore, we are just disposing it
+                }
 
+                // 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();
                 }
@@ -1624,12 +1635,10 @@
     }
 
     /**
-     * Exit the program.
-     * Exit from the program (if not stand alone) - do no clean-up
+     * This function should be called to halt the VM when all applets are destroyed.
      */
     private void appletSystemExit() {
-        // Do nothing. Exit is handled by another
-        // block of code, called when _all_ applets are gone
+        System.exit(0);
     }
 
     /**



More information about the distro-pkg-dev mailing list