From 8a847992137e9da5922f12d9f70273e65d77fe8d Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Wed, 30 Nov 2016 14:57:40 +0200 Subject: [PATCH] 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 --- .../src/org/simantics/trend/impl/TrendNode.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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++) { -- 2.47.1