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-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=c09116b855b4bb4a377be1c573ddbb5d755c0bc1;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 --- 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 3277bbd1e..995ec0fda 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()); }