From 5a9649b1a29b5c43f33e8ee809fcb55480cbdabc Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Fri, 20 Oct 2017 09:18:21 +0300 Subject: [PATCH] Wait for pending transactions when loading scene graph provider Prior to this asynchronously applied styling was missing from exported diagrams. refs #7566 Change-Id: I2fd927ef2b65831fa9fc431a7430a2df7ac8ed6d --- .../diagram/elements/DiagramNodeUtil.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java index 893573d0f..f2cccf774 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java @@ -14,6 +14,7 @@ import org.simantics.db.common.request.ResourceRead; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; +import org.simantics.db.service.TransactionSupport; import org.simantics.db.service.VirtualGraphSupport; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.diagram.ui.DiagramModelHints; @@ -146,22 +147,7 @@ public class DiagramNodeUtil { G2DSceneGraph sg = provider.initializeSceneGraph(new G2DSceneGraph(), modelURI, diagramRVI); NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), sg); - - return cp.getCanvasContext(); - } - - /** - * @deprecated this leaks ICanvasSceneGraphProvider, use - * {@link #loadSceneGraphProvider(ICanvasContext, Resource, Resource, String)} - * instead - */ - public static ICanvasContext loadDiagram(ICanvasContext context, Resource model, Resource composite, String diagramRVI) throws DatabaseException, InterruptedException { - String modelURI = Simantics.getSession().syncRequest(Queries.uri(model)); - ISceneGraphProvider provider = Simantics.getSession().syncRequest( Queries.adapt( composite, ISceneGraphProvider.class ) ); - ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider; - cp.initializeSceneGraph(context, modelURI, diagramRVI); - - NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph()); + Simantics.getSession().getService(TransactionSupport.class).waitCompletion(); return cp.getCanvasContext(); } @@ -173,6 +159,7 @@ public class DiagramNodeUtil { G2DSceneGraph sg = cp.initializeSceneGraph(new G2DSceneGraph(), modelURI, diagramRVI); NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), sg); + Simantics.getSession().getService(TransactionSupport.class).waitCompletion(); return cp; } @@ -188,6 +175,7 @@ public class DiagramNodeUtil { ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider; cp.initializeSceneGraph(context, modelURI, diagramRVI); NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph(), timeoutMs); + Simantics.getSession().getService(TransactionSupport.class).waitCompletion(); return cp; } @@ -197,6 +185,7 @@ public class DiagramNodeUtil { ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider; cp.initializeSceneGraph(context, modelURI, diagramRVI); NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph()); + Simantics.getSession().getService(TransactionSupport.class).waitCompletion(); return cp; } -- 2.47.1