From: Tuukka Lehtonen Date: Fri, 4 Aug 2017 20:52:31 +0000 (+0300) Subject: Fixed CommandContextImpl.merge to not duplicate same values in result X-Git-Tag: v1.31.0~264^2~6 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F807%2F1;p=simantics%2Fplatform.git Fixed CommandContextImpl.merge to not duplicate same values in result According to Antti this was a known and very old problem that should now finally be resolved. refs #7409 Change-Id: I0ab43d7136fca3f3333a81751fc86e0da7085a26 (cherry picked from commit c09116b855b4bb4a377be1c573ddbb5d755c0bc1) --- diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/CommandContextImpl.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/CommandContextImpl.java index 5b49810fa..5fb3a283e 100644 --- a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/CommandContextImpl.java +++ b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/CommandContextImpl.java @@ -66,6 +66,12 @@ public class CommandContextImpl implements CommandContextMutable { if (context != null) { Map>> from = context.getData(); for (Map.Entry>> entry : from.entrySet()) { + String key = entry.getKey(); + Object existing = getValue(key); + Object newValue = context.getValue(key); + // Do not merge duplicates! + if (newValue != null && newValue.equals(existing)) + continue; List> rows = ensureRowsAvailable(entry.getKey()); rows.addAll(entry.getValue()); }