X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fbase%2FSynchronizationEventHandlerBase.java;fp=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fbase%2FSynchronizationEventHandlerBase.java;h=095640c4aa1f0a2185da8bd6a92010421da6d63a;hp=67b120b6462cc10b3e36364c70e884f91f8c9d9c;hb=b000e272429e157638c0384878b07b8dcd758472;hpb=5e7529d05dde6a355305f9af1682de4cc0b31526 diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java index 67b120b64..095640c4a 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java @@ -201,10 +201,14 @@ public abstract class SynchronizationEventHandlerBase // TODO these two lines can be removed when IncludedInSimulation -property is given to all composites if(component.getParent() != null) { - String parentName = solver.getName(component.getParent().getModuleId()); - solver.includeSubprocess(parentName, subprocessName); - component.solverComponentName = subprocessName; - solverComponentNameToComponent.put(subprocessName, component); + int nearestParentId = getNearestParentComponentId(component); + if (nearestParentId <= 0) { + throw new SynchronizationException("Could not find parent with non-zero component id from Component("+name+", " + (component != null ? component.uid : "null") + "," + typeId + ")"); + } + String parentName = solver.getName(nearestParentId); + solver.includeSubprocess(parentName, subprocessName); + component.solverComponentName = subprocessName; + solverComponentNameToComponent.put(subprocessName, component); } if(updater.isComposite) { @@ -334,6 +338,17 @@ public abstract class SynchronizationEventHandlerBase } } + private static int getNearestParentComponentId(ComponentBase component) { + ComponentBase parent = component.getParent(); + while (parent != null) { + int pid = parent.getModuleId(); + if (pid > 0) + return pid; + parent = parent.getParent(); + } + return -1; + } + protected void addPendingRemoval(T component) { if (TRACE_EVENTS) System.out.println("addPendingRemoval(" + component.componentId + " : " + component.solverComponentName + ")");