From: Tuukka Lehtonen Date: Wed, 30 Nov 2016 12:57:40 +0000 (+0200) Subject: Fixed regression in TrendNode. X-Git-Tag: v1.25.0~23 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=8a847992137e9da5922f12d9f70273e65d77fe8d;p=simantics%2Fplatform.git Fixed regression in TrendNode. The regression was caused by change r32901 and merge r32981. The problem was that the code tried to keep existing VertRuler nodes alive as much as possible to keep their (transient) settings in place between chart configuration reloads. However the code failed to do this correctly and caused IndexOutOfBoundsExceptions and other corollary failures. This fix needs to go into platform branches 1.22.2 and 1.22 as well. refs #6547 [PRIVATE-11736] Change-Id: Idb7d9d77b1a6b0bf513a5829b4c373cde9747529 --- diff --git a/bundles/org.simantics.trend/src/org/simantics/trend/impl/TrendNode.java b/bundles/org.simantics.trend/src/org/simantics/trend/impl/TrendNode.java index 1d19e2f17..304b73c43 100644 --- a/bundles/org.simantics.trend/src/org/simantics/trend/impl/TrendNode.java +++ b/bundles/org.simantics.trend/src/org/simantics/trend/impl/TrendNode.java @@ -60,7 +60,6 @@ import org.simantics.utils.format.ValueFormat; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TObjectProcedure; public class TrendNode extends G2DParentNode implements TrendLayout { @@ -276,7 +275,6 @@ public class TrendNode extends G2DParentNode implements TrendLayout { TObjectIntMap newItemMap = itemIndexMap(newSpec.items); TObjectIntMap currentItemMap = itemIndexMap(spec.items); - TObjectIntMap addedItemMap = subtract(newItemMap, currentItemMap); TObjectIntMap removedItemMap = subtract(currentItemMap, newItemMap); Map existingRulers = new HashMap<>(); if (this.spec.axisMode == YAxisMode.MultiAxis) { @@ -347,6 +345,9 @@ public class TrendNode extends G2DParentNode implements TrendLayout { for (int i=0; i() { @Override public boolean execute(String id) { @@ -358,13 +359,11 @@ public class TrendNode extends G2DParentNode implements TrendLayout { return true; } }); - addedItemMap.forEachValue(new TIntProcedure() { - @Override - public boolean execute(int index) { - vertRulers.add( index, addNode(VertRuler.class) ); - return true; - } - }); + // Ensure TODO: validate that this works also for keeping ruler settings + for (int i = vertRulers.size(); i < analogItems.size(); ++i) { + VertRuler ruler = addNode(VertRuler.class); + vertRulers.add(ruler); + } } for (int i = 0; i < analogItems.size(); i++) {