From af6154113f5df8d3990d19fcdfd4667f1715ca48 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Mon, 24 Jan 2022 17:00:02 +0200 Subject: [PATCH] We must use adaptUnique for getting chart object from DB. Otherwise, DB may return disposed chart. gitlab #86 --- .../src/org/simantics/jfreechart/chart/ChartComposite.java | 2 +- .../src/org/simantics/jfreechart/chart/ChartComposite2.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; } -- 2.47.1