aboutsummaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorDeepak Bhole <[email protected]>2011-05-02 14:33:32 -0400
committerDeepak Bhole <[email protected]>2011-05-02 14:33:32 -0400
commit44e1d8f721f0d1428e9f34573e9964e6287d5e64 (patch)
treed9578ed5b92bc1a93ed6e0119535e4efad71891f /plugin
parent56d85fafd578e28fc17211d28f4f0a701192e789 (diff)
Prevent applet from shutting down down if another tab with the same page is
opened and closed.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginAppletViewer.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
index d974ca9..cc1f716 100644
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
@@ -1621,15 +1621,26 @@ public class PluginAppletViewer extends XEmbeddedFrame
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();
}
@@ -1640,12 +1651,10 @@ public class PluginAppletViewer extends XEmbeddedFrame
}
/**
- * 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);
}
/**