]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/scl/issue/SCLExpressionIssueProvider.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / scl / issue / SCLExpressionIssueProvider.java
index fbba1546ffbc2a0e81a75c95bea69c6e290b9584..46142247f47855efcb3a78ca351568a3404d89da 100644 (file)
@@ -12,12 +12,13 @@ import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.simantics.Simantics;
+import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Disposable;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.AsyncListenerAdapter;
 import org.simantics.db.common.procedure.adapter.DisposableListener;
 import org.simantics.db.common.procedure.adapter.DisposableSyncListener;
-import org.simantics.db.common.procedure.adapter.SyncListenerAdapter;
 import org.simantics.db.common.request.TernaryRead;
 import org.simantics.db.common.request.UnaryRead;
 import org.simantics.db.common.request.UniqueRead;
@@ -145,7 +146,11 @@ public class SCLExpressionIssueProvider implements SCLIssueProvider {
             if (!graph.hasStatement(parameter))
                 return null;
             
-            Variable componentVariable = Variables.getVariable(graph, parameter);
+            Variable componentVariable = Variables.getPossibleVariable(graph, parameter);
+            if (componentVariable == null) {
+                // Resource might be deleted already and therefore no URI available for variable building
+                return null;
+            }
             Variable propertyVariable = componentVariable.getProperty(graph, parameter2);
             
             Variable typeVariable = Variables.getVariable(graph, type);
@@ -180,7 +185,7 @@ public class SCLExpressionIssueProvider implements SCLIssueProvider {
         }
     }
     
-    private static class ComponentSyncListenerAdapter extends SyncListenerAdapter<Set<Resource>> implements Disposable {
+    private static class ComponentSyncListenerAdapter extends AsyncListenerAdapter<Set<Resource>> implements Disposable {
 
         private ConcurrentHashMap<Resource, SCLValueDisposableSyncListener> currentlyListening = new ConcurrentHashMap<>();
         private boolean disposed;
@@ -191,7 +196,7 @@ public class SCLExpressionIssueProvider implements SCLIssueProvider {
         }
         
         @Override
-        public void execute(ReadGraph graph, Set<Resource> newComponents) {
+        public void execute(AsyncReadGraph graph, Set<Resource> newComponents) {
             if (currentlyListening.isEmpty() && newComponents.isEmpty()) {
                 // we can stop here as nothing will change
                 return;