Преглед изворни кода

bug fix for incorrect drawn node links.

Pamela Wolf пре 5 година
родитељ
комит
075c51470b
2 измењених фајлова са 22 додато и 5 уклоњено
  1. 17 2
      nodeEditor/src/diagram/graphCanvas.tsx
  2. 5 3
      nodeEditor/src/diagram/nodeLink.ts

+ 17 - 2
nodeEditor/src/diagram/graphCanvas.tsx

@@ -815,11 +815,15 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
             return;
         }
 
+        let linksToNotifyForDispose: Nullable<NodeLink[]> = null;
+
         if (pointB.isConnected) {
             let links = nodeB.getLinksForConnectionPoint(pointB);
 
+            linksToNotifyForDispose = links.slice();
+
             links.forEach(link => {
-                link.dispose();
+                link.dispose(false);
             });
         }
 
@@ -827,8 +831,14 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
             pointB.ownerBlock.inputs.forEach(i => {
                 let links = nodeB.getLinksForConnectionPoint(i);
 
+                if (!linksToNotifyForDispose) {
+                    linksToNotifyForDispose = links.slice();
+                } else {
+                    linksToNotifyForDispose.push(...links.slice());
+                }
+
                 links.forEach(link => {
-                    link.dispose();
+                    link.dispose(false);
                 });
             })
         }
@@ -876,6 +886,11 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
             nodeB.refresh();
         }
 
+        linksToNotifyForDispose?.forEach((link) => {
+            link.onDisposedObservable.notifyObservers(link);
+            link.onDisposedObservable.clear();
+        });
+
         this.props.globalState.onRebuildRequiredObservable.notifyObservers();
     }
 

+ 5 - 3
nodeEditor/src/diagram/nodeLink.ts

@@ -128,7 +128,7 @@ export class NodeLink {
         this._graphCanvas.globalState.onSelectionChangedObservable.notifyObservers(this);
     }
 
-    public dispose() {
+    public dispose(notify = true) {
         this._graphCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
 
         if (this._path.parentElement) {
@@ -147,8 +147,10 @@ export class NodeLink {
             this._portA.connectionPoint.disconnectFrom(this._portB!.connectionPoint);
         }
 
-        this.onDisposedObservable.notifyObservers(this);
+        if (notify) {
+            this.onDisposedObservable.notifyObservers(this);
 
-        this.onDisposedObservable.clear();
+            this.onDisposedObservable.clear();
+        }
     }
 }