]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
JFreeChart implementation is leaking memory
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 9 Dec 2021 17:26:24 +0000 (19:26 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 9 Dec 2021 17:26:24 +0000 (19:26 +0200)
Take account that new PlotProperties may contain the same objects as the
old one.

gitlab #86

bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java

index 2d5daec8770c87a87862cec81eb14a6398879446..5f7c15ef9d84d70a316222aec2925827a1e92da5 100644 (file)
@@ -91,13 +91,16 @@ public abstract class AbstractPlot implements IPlot {
     protected void setPlotProperties(PlotProperties properties) {
                if (currentProperties != null) {
                        for (IAxis axis : currentProperties.ranges)
-                               axis.dispose();
+                               if (!properties.ranges.contains(axis))
+                                       axis.dispose();
 
                        for (IAxis axis : currentProperties.domains)
-                               axis.dispose();
+                               if (!properties.domains.contains(axis))
+                                       axis.dispose();
 
                        for (IDataset dataset : currentProperties.datasets)
-                               dataset.dispose();
+                               if (!properties.datasets.contains(dataset))
+                                       dataset.dispose();
                }
                this.currentProperties = properties;
     }