Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / ExternalReadEntry.java
index 6253744bb05e26d012ff3b86906e465fc9911e95..2980b9b15f72e9a54b00a96fe06a397ef60b59b6 100644 (file)
@@ -28,7 +28,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     final LinkedList<T> items = new LinkedList<T>();
 
     protected ExternalRead<T> id;
-    protected ReadGraphImpl graph;
+    protected QueryProcessor processor;
     protected boolean registered = false;
 
     @Override
@@ -49,7 +49,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     public void discard() {
         id.unregistered();
         id = null;
-        graph = null;
+        processor = null;
         super.discard();
     }
 
@@ -65,7 +65,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     public ExternalReadEntry(ExternalRead<T> request, ReadGraphImpl graph) {
         assert request != null;
         this.id = request;
-        this.graph = graph;
+        this.processor = graph.processor;
     }
     
     @Override
@@ -213,7 +213,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
 
                synchronized(items) {
                        items.addLast(result);
-                               graph.processor.updatePrimitive(id);
+                               processor.updatePrimitive(id);
                        // TODO: implement flags/logic in ExternalRead to state that all but the latest request result can be evaporated
                        // In some cases where data is produced really fast this might be necessary but currently this queueing will do.
                }
@@ -229,7 +229,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
 
        @Override
        public boolean isDisposed() {
-               return registered && (isDiscarded() || !graph.processor.isBound(this));
+               return registered && (isDiscarded() || !processor.isBound(this));
        }
 
     @Override