Skip to content

Commit 2340a0b

Browse files
committed
Forbid connection making a loop on a single node (paceholder#111)
1 parent 445554e commit 2340a0b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Node.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ id() const
8686
void
8787
Node::
8888
reactToPossibleConnection(PortType reactingPortType,
89-
9089
NodeDataType reactingDataType,
9190
QPointF const &scenePoint)
9291
{

src/NodeConnectionInteraction.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ canConnect(PortIndex &portIndex, bool& typeConversionNeeded, std::unique_ptr<Nod
3333

3434
PortType requiredPort = connectionRequiredPort();
3535

36+
3637
if (requiredPort == PortType::None)
3738
{
3839
return false;
3940
}
4041

42+
// 1.5) Forbid connecting the node to itself
43+
Node* node = _connection->getNode(oppositePort(requiredPort));
44+
45+
if (node == _node)
46+
return false;
47+
4148
// 2) connection point is on top of the node port
4249

4350
QPointF connectionPoint = connectionEndScenePosition(requiredPort);
@@ -89,7 +96,7 @@ tryConnect() const
8996
{
9097
return false;
9198
}
92-
99+
93100
/// 1.5) If the connection is possible but a type conversion is needed, add a converter node to the scene, and connect it properly
94101
if (typeConversionNeeded)
95102
{

src/NodeConnectionInteraction.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class NodeConnectionInteraction
5959
QPointF const &p) const;
6060

6161
bool nodePortIsEmpty(PortType portType, PortIndex portIndex) const;
62-
62+
6363
private:
6464

6565
Node* _node;
6666

6767
Connection* _connection;
68-
68+
6969
FlowScene* _scene;
7070
};
71-
}
71+
}

0 commit comments

Comments
 (0)