]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/viewpoints/ViewpointStub.java
Still working for multiple readers
[simantics/platform.git] / bundles / org.simantics.browsing.ui.common / src / org / simantics / browsing / ui / common / viewpoints / ViewpointStub.java
index 4895d3f75425ed00df79a8703c7656a41e52c18a..b33b57a0b720df1b5a20f5b0aefcd1c57260afb0 100644 (file)
@@ -29,10 +29,21 @@ public abstract class ViewpointStub implements Viewpoint {
     protected Boolean        hasChildren = Viewpoint.PENDING_HAS_CHILDREN;
 
     final public void setChildren(PrimitiveQueryUpdater updater, NodeContext[] children) {
+       
         if (children == null)
             throw new NullPointerException(this + ": null children produced by " + getClass().getName());
-        for(NodeContext c : children) updater.incRef(c);
-        for(NodeContext c : this.children) updater.decRef(c);
+        
+        final NodeContext[] currentChildren = this.children;
+        
+        updater.execFromQuery(new Runnable() {
+
+                       @Override
+                       public void run() {
+                       for(NodeContext c : children) updater.incRef(c);
+                       for(NodeContext c : currentChildren) updater.decRef(c);
+                       }
+               
+        });
         this.children = children;
     }