]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix synchronization of PipingRules.currentUpdates. 60/3860/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Tue, 11 Feb 2020 07:33:41 +0000 (09:33 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Tue, 11 Feb 2020 07:34:12 +0000 (09:34 +0200)
gitlab #76

Change-Id: I2a9a7566f5775d5f71552e39da65f2429be91e69

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java

index 08675c242a35da019450f444a52153a1cfb64d14..2c5f7427c7143430beb56edb57583ee31fbafbbb 100644 (file)
@@ -138,8 +138,11 @@ public class PipingRules {
        
        public static void setEnabled(boolean enabled) {
                PipingRules.enabled = enabled;
-               if(!enabled)
-                       currentUpdates.clear();
+               if(!enabled) {
+                       synchronized (ruleMutex) {
+                               currentUpdates.clear();
+                       }
+               }
        }
        
        public static boolean isEnabled() {
@@ -908,7 +911,11 @@ public class PipingRules {
                Vector3d dir = new Vector3d();
                dir.sub(currentPos, prevPos);
                
-               boolean simple = currentUpdates.contains(icp);
+               boolean simple;
+               synchronized (ruleMutex) {
+                       simple = currentUpdates.contains(icp);
+               }
+               
                if (simple) {
                        // Update based on position -> adjust length
                        double currentLength = (dir.length() - prev.getInlineLength()) * 2.0;