Skip to content

Commit

Permalink
Do not enter an infinite loop in mergePoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaurycyLiebner committed Mar 6, 2021
1 parent df0c49a commit adf8135
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CORE_EXPORT Canvas : public CanvasBase {

void mergePoints();
void disconnectPoints();
void connectPoints();
bool connectPoints();
void subdivideSegments();

void setSelectedTextAlignment(const Qt::Alignment alignment) const;
Expand Down
9 changes: 5 additions & 4 deletions src/core/canvasselectedpointsactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ QList<SmartNodePoint*> Canvas::getSortedSelectedNodes() {
return nodes;
}

void Canvas::connectPoints() {
bool Canvas::connectPoints() {
prp_pushUndoRedoName("Connect Nodes");
const auto nodes = getSortedSelectedNodes();
QList<SmartNodePoint*> endNodes;
Expand All @@ -57,8 +57,9 @@ void Canvas::connectPoints() {
const int targetId2 = node2->getNodeId();
const auto sel2 = handler->getPointWithId<SmartNodePoint>(targetId2);
addPointToSelection(sel2);
}
} else return false;
}
return true;
}

void Canvas::disconnectPoints() {
Expand Down Expand Up @@ -86,8 +87,8 @@ void Canvas::mergePoints() {
firstPoint->getNextPoint() == secondPoint;
if(!ends && !neigh) return;
if(ends) {
connectPoints();
mergePoints();
const bool success = connectPoints();
if(success) mergePoints();
return;
}
removePointFromSelection(secondPoint);
Expand Down

0 comments on commit adf8135

Please sign in to comment.