]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / CacheEntryBase.java
index 3a94e52b6f9dd58f55031b852df02776fc044874..74e39ab9513f92500aaa8878ce668417a5047e57 100644 (file)
@@ -145,8 +145,9 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     }
 
     @Override
-    public void setPending() {
-       statusOrException = PENDING;
+    public void setPending(QuerySupport querySupport) {
+        statusOrException = PENDING;
+        clearResult(querySupport);
     }
     
     @Override
@@ -276,7 +277,31 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
        }
         
     }
-    
+
+    @Override
+    void pruneParentSet() {
+        // First parent is discarded => look for more parents
+        if(p2OrParents instanceof QueryIdentityHashSet) {
+
+            QueryIdentityHashSet set = (QueryIdentityHashSet)p2OrParents;
+            set.removeDiscardedReally();
+            if(set.isEmpty()) p2OrParents = null;
+
+        } else if(p2OrParents instanceof CacheEntry) {
+
+            CacheEntry entry = (CacheEntry)p2OrParents;
+            if(entry.isDiscarded()) {
+                // Second entry is also discarded => all empty
+                p2OrParents = null;
+            }
+
+        } else {
+
+            // Nothing left
+
+        }
+    }
+
     @Override
     final public void removeParent(CacheEntry entry) {
        
@@ -439,8 +464,7 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     void prepareRecompute(QuerySupport querySupport) {
-               setPending();
-               clearResult(querySupport);
+        setPending(querySupport);
     }
     
     @Override