]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed CommandContextImpl.merge to not duplicate same values in result 04/804/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 4 Aug 2017 20:52:31 +0000 (23:52 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 4 Aug 2017 20:52:31 +0000 (23:52 +0300)
According to Antti this was a known and very old problem that should now
finally be resolved.

refs #7409

Change-Id: I0ab43d7136fca3f3333a81751fc86e0da7085a26

bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/CommandContextImpl.java

index 3277bbd1edfe02440a1b944f7f6c192c4808875c..995ec0fda361ff92143b20bcb2268e7901de5ee7 100644 (file)
@@ -66,6 +66,12 @@ public class CommandContextImpl implements CommandContextMutable {
                if (context != null) {
                        Map<String,List<List<Object>>> from = context.getData(); 
                        for (Map.Entry<String, List<List<Object>>> 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<List<Object>> rows = ensureRowsAvailable(entry.getKey());
                                rows.addAll(entry.getValue());
                        }