From: Reino Ruusu Date: Tue, 11 Feb 2020 07:33:41 +0000 (+0200) Subject: Fix synchronization of PipingRules.currentUpdates. X-Git-Tag: v1.43.0~80 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=8334f50b69e1cdba45ed26d49f193d26d728b1fc;p=simantics%2F3d.git Fix synchronization of PipingRules.currentUpdates. gitlab #76 Change-Id: I2a9a7566f5775d5f71552e39da65f2429be91e69 --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index 08675c24..2c5f7427 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -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;