[UI Hierarchy] fix a bug - After export image file, image file can not be opened...
authorjungwook.ryu <jungwook.ryu@samsung.com>
Wed, 23 Dec 2015 11:42:54 +0000 (20:42 +0900)
committerJaewon Lim <jaewon81.lim@samsung.com>
Wed, 23 Dec 2015 13:01:35 +0000 (22:01 +0900)
Change-Id: If3d544ef0115cfd2d736fe1fde0bd82fbcd8d2b2
Signed-off-by: jungwook.ryu <jungwook.ryu@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/tool/HierarchyTreeExporter.java

index 0741bde..f7904a1 100644 (file)
@@ -28,6 +28,7 @@ package org.tizen.dynamicanalyzer.ui.hierarchy.tree.tool;
 
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.SWTGraphics;
@@ -150,9 +151,11 @@ public class HierarchyTreeExporter {
                         * Export image file to above location
                         */
                        boolean result = true;
+                       ImageLoader loader;
+                       FileOutputStream os = null;
                        try {
-                               FileOutputStream os = new FileOutputStream(exportPath);
-                               ImageLoader loader = new ImageLoader();
+                               os = new FileOutputStream(exportPath);
+                               loader = new ImageLoader();
                                loader.data = new ImageData[] { image.getImageData() };
                                loader.save(os, SWT.IMAGE_PNG);
                                latestExportDir = currentExportDir;
@@ -160,6 +163,14 @@ public class HierarchyTreeExporter {
                                Logger.error(e);
                                result = false;
                        } finally {
+                               try {
+                                       if (os != null) {
+                                               os.close();
+                                       }
+                               } catch (IOException e) {
+                                       result = false;
+                                       Logger.exception(e);
+                               }
                                image.dispose();
                        }
                        if (result == true) {