[libbluray-devel] Properly dispose HScene

hpi1 git at videolan.org
Tue Dec 10 10:24:49 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Dec 10 10:33:54 2013 +0200| [24d4a73f2f0a8cd7c40f83909cdefda70e56ccf3] | committer: hpi1

Properly dispose HScene

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

 src/libbluray/bdj/java/org/havi/ui/HScene.java     |   30 ++++++++++++++++++--
 .../bdj/java/org/havi/ui/HSceneFactory.java        |    1 +
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/org/havi/ui/HScene.java b/src/libbluray/bdj/java/org/havi/ui/HScene.java
index 336b91a..390ddac 100644
--- a/src/libbluray/bdj/java/org/havi/ui/HScene.java
+++ b/src/libbluray/bdj/java/org/havi/ui/HScene.java
@@ -242,8 +242,34 @@ public class HScene extends Container implements HComponentOrdering {
         return null;
     }
 
-    public void dispose() {
-        // TODO not implemented
+    public synchronized void dispose() {
+        if (null != BDJXletContext.getCurrentContext())
+            HSceneFactory.getInstance().dispose(this);
+    }
+
+    protected void disposeImpl()
+    {
+        // called by HSceneFactory
+        try {
+            removeAll();
+
+            Graphics g = GUIManager.getInstance().getGraphics();
+            Rectangle r = getBounds();
+            g.clearRect(r.x, r.y, r.width, r.height);
+
+            if (image != null) {
+                image.flush();
+            }
+            if (shortcuts != null) {
+                shortcuts.clear();
+            }
+        } finally {
+            image = null;
+            eventGroup = null;
+            shortcuts = null;
+            windowListener = null;
+            context = null;
+        }
     }
 
     public boolean addShortcut(int keyCode, HActionable act) {
diff --git a/src/libbluray/bdj/java/org/havi/ui/HSceneFactory.java b/src/libbluray/bdj/java/org/havi/ui/HSceneFactory.java
index 4f2318c..b6e9fb9 100644
--- a/src/libbluray/bdj/java/org/havi/ui/HSceneFactory.java
+++ b/src/libbluray/bdj/java/org/havi/ui/HSceneFactory.java
@@ -109,6 +109,7 @@ public class HSceneFactory extends Object {
             logger.error("wrong HScene");
         }
 
+        scene.disposeImpl();
         GUIManager.getInstance().remove(scene);
         defaultHScene = null;
     }



More information about the libbluray-devel mailing list