[libbluray-devel] Fix BDToolkit shutdown so that BD-J can be restarted for new disc

hpi1 git at videolan.org
Tue Mar 4 11:03:42 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Mar  4 12:01:15 2014 +0200| [4edb63c624ba30f16509bbb6caf70c4c082acb6e] | committer: hpi1

Fix BDToolkit shutdown so that BD-J can be restarted for new disc

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=4edb63c624ba30f16509bbb6caf70c4c082acb6e
---

 .../bdj/java-j2se/java/awt/BDToolkit.java          |    4 +--
 src/libbluray/bdj/java/java/awt/BDToolkitBase.java |   28 +++++++++++++-------
 src/libbluray/bdj/java/org/videolan/Libbluray.java |    2 +-
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java b/src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java
index 7b7fdd5..9c04aea 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java
@@ -31,8 +31,8 @@ public class BDToolkit extends BDToolkitBase implements KeyboardFocusManagerPeer
     public BDToolkit () {
     }
 
-    public void dispose() {
-        super.dispose();
+    protected void shutdown() {
+        super.shutdown();
 
         KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
         KeyboardFocusManager.getCurrentKeyboardFocusManager().setGlobalCurrentFocusCycleRoot(null);
diff --git a/src/libbluray/bdj/java/java/awt/BDToolkitBase.java b/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
index 0940b36..42ff304 100644
--- a/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
+++ b/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
@@ -45,25 +45,37 @@ abstract class BDToolkitBase extends Toolkit {
     private static Hashtable cachedImages = new Hashtable();
     private static final Logger logger = Logger.getLogger(BDToolkit.class.getName());
 
+    // mapping of Components to AppContexts, WeakHashMap<Component,AppContext>
+    private static final Map contextMap = Collections.synchronizedMap(new WeakHashMap());
+
+
     public BDToolkitBase () {
     }
 
     public static void setFocusedWindow(Window window) {
     }
 
-    public static void shutdown() {
-        Toolkit toolkit = getDefaultToolkit();
-        if (toolkit instanceof BDToolkit) {
-            ((BDToolkit)toolkit).dispose();
+    public static void shutdownDisc() {
+        try {
+            Toolkit toolkit = getDefaultToolkit();
+            if (toolkit instanceof BDToolkit) {
+                ((BDToolkit)toolkit).shutdown();
+            }
+        } catch (Throwable t) {
+            logger.error("shutdownDisc() failed: " + t);
+            t.printStackTrace();
         }
     }
 
-    public void dispose() {
+    protected void shutdown() {
+        /*
         if (eventQueue != null) {
             BDJHelper.stopEventQueue(eventQueue);
             eventQueue = null;
         }
-        cachedImages = null;
+        */
+        cachedImages.clear();
+        contextMap.clear();
     }
 
     public Dimension getScreenSize() {
@@ -185,10 +197,6 @@ abstract class BDToolkitBase extends Toolkit {
     public void beep() {
     }
 
-    // mapping of Components to AppContexts, WeakHashMap<Component,AppContext>
-    private static final Map contextMap =
-        Collections.synchronizedMap(new WeakHashMap());
-
     public static void addComponent(Component component) {
 
         BDJXletContext context = BDJXletContext.getCurrentContext();
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 18d4aab..0587121 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -129,7 +129,7 @@ public class Libbluray {
             BDJActionManager.getInstance().finalize();
             MountManager.unmountAll();
             GUIManager.shutdown();
-            BDToolkit.shutdown();
+            BDToolkit.shutdownDisc();
         } catch (Throwable e) {
             e.printStackTrace();
         }



More information about the libbluray-devel mailing list