Commit d961999c authored by Tuukka Lehtonen's avatar Tuukka Lehtonen
Browse files

Fix trend PDF export to use separate worker thread

This is the simplest possible fix for the problem. However it relies on
PrintUtil being invoked from a dedicated worker thread, not a shared
thread like AWT or SWT. Previously PrintUtil.TrendPage was hardcoded to
use AWTThread as the CanvasContext thread but switching this to
CurrentThread avoids the previous race conditions.

gitlab #703
parent acc30022
......@@ -133,7 +133,7 @@ public class ExportDiagramPdf implements ExportClass {
boolean isComposite = ctx.session.syncRequest( Queries.isInstanceOf(resource, STR.Composite) );
if ( !isComposite ) {
resource = ctx.session.syncRequest( Queries.possibleObjectWithType(resource, L0.ConsistsOf, STR.Composite) );
isComposite = ctx.session.syncRequest( Queries.isInstanceOf(resource, STR.Composite) );
isComposite = resource != null && ctx.session.syncRequest( Queries.isInstanceOf(resource, STR.Composite) );
}
if ( !isComposite ) {
throw new ExportException(content.url+" doesnt contain a diagram.");
......
......@@ -35,6 +35,7 @@ import org.simantics.utils.page.MarginUtils;
import org.simantics.utils.page.PageDesc;
import org.simantics.utils.page.PageOrientation;
import org.simantics.utils.threads.AWTThread;
import org.simantics.utils.threads.CurrentThread;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
......@@ -171,7 +172,7 @@ public class PrintUtil {
public static TrendPage createFrom(TrendNode srcTrend)
{
TrendPage page = new TrendPage();
CanvasContext ctx = TrendInitializer.createDefaultCanvas(AWTThread.getThreadAccess(), srcTrend.historian, srcTrend.collector, null, srcTrend.getTrendSpec());
CanvasContext ctx = TrendInitializer.createDefaultCanvas(CurrentThread.getThreadAccess(), srcTrend.historian, srcTrend.collector, null, srcTrend.getTrendSpec());
TrendNode trend = TrendInitializer.getTrendNode( ctx );
trend.setViewport( srcTrend.getViewport() );
page.autoscale = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment