From: Marko Luukkainen Date: Mon, 24 Jan 2022 15:00:02 +0000 (+0200) Subject: We must use adaptUnique for getting chart object from DB. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=af6154113f5df8d3990d19fcdfd4667f1715ca48;p=simantics%2Fsysdyn.git We must use adaptUnique for getting chart object from DB. Otherwise, DB may return disposed chart. gitlab #86 --- diff --git a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java index 53cdf1c4..bd898d89 100644 --- a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java +++ b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java @@ -113,7 +113,7 @@ public class ChartComposite extends Composite { public IJFreeChart perform(ReadGraph graph) throws DatabaseException { // Adapt chartResource to a chart (XY, pie, bar, ...) if(graph.isInstanceOf(chartResource, JFreeChartResource.getInstance(graph).Chart)) { - return graph.adapt(chartResource, IJFreeChart.class); + return graph.adaptUnique(chartResource, IJFreeChart.class); } else { return null; } diff --git a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite2.java b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite2.java index 0efffbc3..bdd275ad 100644 --- a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite2.java +++ b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite2.java @@ -143,7 +143,7 @@ public class ChartComposite2 extends SWTAWTComponent { public IJFreeChart perform(ReadGraph graph) throws DatabaseException { // Adapt chartResource to a chart (XY, pie, bar, ...) if(graph.isInstanceOf(chartResource, JFreeChartResource.getInstance(graph).Chart)) { - return graph.adapt(chartResource, IJFreeChart.class); + return graph.adaptUnique(chartResource, IJFreeChart.class); } else { return null; }