From: Jussi Koskela Date: Fri, 20 Oct 2017 06:18:21 +0000 (+0300) Subject: Wait for pending transactions when loading scene graph provider X-Git-Tag: v1.31.0~104 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F1132%2F2;p=simantics%2Fplatform.git 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 --- 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; }