]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Improved clearing of CanvasContext 45/4645/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 5 Feb 2021 15:05:35 +0000 (17:05 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 5 Feb 2021 15:05:35 +0000 (17:05 +0200)
gitlab #674

Change-Id: Ib2e6d13346576f6852f30fa31c08adc0b638db13

bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/AbstractHintObservable.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/HintStack.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/prioritystack/PriorityStack.java

index 998b8a9a28aa155eadd889656b899c6b111d7d9a..cf9cff75cc771d2f4419c5576942910d9925abe3 100644 (file)
@@ -191,6 +191,7 @@ public class CanvasContext extends Context<ICanvasParticipant> implements ICanva
                 }
                 // HN: added to decrease memory leaks
                 eventHandlerStack = null;
+                hintStack.clear();
                 hintStack = null;
                 canvasNode.cleanup();
                 canvasNode = null;
index aacadc1a6a5671ac292c0a592abee0a690ff20ee..bbe2447c970dbb70b5bc59c1021d4789ebf0813d 100644 (file)
@@ -255,5 +255,10 @@ public abstract class AbstractHintObservable implements IHintObservable {
                list.remove(threadAccess, listener);
                if (list.isEmpty()) keyListeners.remove(key);           
        }
+       
+       public void clear() {
+               keyListeners.clear();
+               listeners.clear();
+       }
                
 }
index 2be216d30df840a8e9147501b2b19e42b215b3ba..d6af390e6bc89497a7c831a4f69bc6e92689de05 100644 (file)
@@ -333,4 +333,9 @@ public class HintStack extends AbstractHintObservable implements IHintStack {
                        }};
        }
        
+       public void clear() {
+               super.clear();
+               stack.clear();
+       }
+       
 }
index 81029105d203b77c32fc92171fd9d4622918f28c..6c0a36acd514f329f8cd06d7b76ec6d8bc58a2f4 100644 (file)
@@ -197,5 +197,15 @@ public class PriorityStack<E> implements IPriorityStack<E> {
        public String toString() {
            return EString.implode(snapshotArray, "\n");
        }
+       
+       public void clear() {
+               if (list != null) {
+                       list.clear();
+               }
+               if (listeners != null) {
+                       listeners.clear();
+               }
+               snapshotArray = createArray(0);
+       }
 
 }