Export: remove memleaks 62/10562/2
Calixte DENIZET [Thu, 21 Feb 2013 17:24:04 +0000 (18:24 +0100)]
Change-Id: I870ff6ba5a694683afb7749bfeaafdf569021872

scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/Export.java

index 48b0b4b..2b4d4ec 100644 (file)
@@ -217,6 +217,8 @@ public class Export {
                 GraphicController.getController().unregister(visitor);
                 DrawerVisitor.changeVisitor(figure, oldVisitor);
                 exporter.dispose();
+                exporter = null;
+                visitorsToExp.remove(visitor);
             }
         } else {
             DrawerVisitor visitor = DrawerVisitor.getVisitor(uid);
@@ -237,9 +239,11 @@ public class Export {
             } finally {
                 if (exporter != null) {
                     exporter.dispose();
+                    exporter = null;
                     visitorsToExp.remove(visitor);
                 }
                 DrawerVisitor.changeVisitor(figure, null);
+                GraphicController.getController().unregister(visitor);
             }
         }
 
@@ -320,6 +324,7 @@ public class Export {
                 PNGExporter exporter = (PNGExporter) getExporter(type);
                 exporter.setImage(file, image, params);
                 exporter.write();
+                exporter.dispose();
             }
         }
     }