Merge remote-tracking branch 'origin/development' into development
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 17 Jul 2019 10:50:07 +0000 (12:50 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 17 Jul 2019 10:50:07 +0000 (12:50 +0200)
1  2 
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java

@@@ -17,7 -17,6 +17,7 @@@ import net.mograsim.logic.model.editor.
  import net.mograsim.logic.model.editor.states.EditorState;
  import net.mograsim.logic.model.model.ViewModelModifiable;
  import net.mograsim.logic.model.model.components.GUIComponent;
 +import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
  import net.mograsim.logic.model.model.wires.GUIWire;
  import net.mograsim.logic.model.model.wires.MovablePin;
  import net.mograsim.logic.model.model.wires.Pin;
@@@ -87,7 -86,7 +87,7 @@@ public class HandleManage
                        ViewModelModifiable model = editor.getSubmodel();
                        Map<String, GUIComponent> compsByName = model.getComponentsByName();
                        Set<GUIComponent> comps = new HashSet<>(compsByName.values());
 -                      GUIComponent interfaceComp = compsByName.get("_submodelinterface");
 +                      GUIComponent interfaceComp = compsByName.get(SubmodelComponent.SUBMODEL_INTERFACE_NAME);
                        comps.remove(interfaceComp);
                        registerInterfaceComponent(interfaceComp);
                        comps.forEach(c -> registerComponent(c));
                {
                        Point[] newPath = w.getPath();
                        int newLength = newPath == null ? 0 : newPath.length;
-                       int diff = oldLength.getAndSet(newLength) - newLength;
+                       int diff = newLength - oldLength.getAndSet(newLength);
                        if (diff != 0)
                        {
                                if (diff > 0)
  
        void destroyWirePointHandle(GUIWire owner, WirePointHandle h)
        {
-               List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
-               int pointIndex = handles.indexOf(h);
-               handles.remove(pointIndex);
-               removeHandle(h);
-               owner.removePathPoint(pointIndex);
+               if (pointHandlesPerWire.containsKey(owner))
+               {
+                       List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
+                       int pointIndex = handles.indexOf(h);
+                       handles.remove(pointIndex);
+                       removeHandle(h);
+                       owner.removePathPoint(pointIndex);
+               }
        }
  
        private void removeWirePointHandles(GUIWire owner)
        {
                EditorState entryState = editor.stateManager.getState();
  
 +              // TODO: As soon as wires connected to a component being removed also are removed, change priority
                if (!cornerHandle.click(clicked.x, clicked.y, stateMask, entryState))
                        if (!click(handlePerPin.values(), clicked, entryState, stateMask))
                                if (!click(handlePerInterfacePin.values(), clicked, entryState, stateMask))