Skip to content

Commit

Permalink
Avoid creating multiple polygon points at the same location
Browse files Browse the repository at this point in the history
When creating a polygon or polyline, it was easy to end up with multiple
points placed at the same location. Since this is basically never
intended, additional clicks on the same location will now be ignored.

Thanks to @Aranda for pointing out this issue and suggesting this fix.
  • Loading branch information
bjorn committed Oct 15, 2011
1 parent b11f6a8 commit 058c752
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/tiled/createobjecttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ void CreateObjectTool::mousePressed(QGraphicsSceneMouseEvent *event)
else
cancelNewMapObject();
} else if (event->button() == Qt::LeftButton) {
QPolygonF current = mNewMapObjectItem->mapObject()->polygon();
QPolygonF next = mOverlayPolygonObject->polygon();

// If the last position is still the same, ignore the click
if (next.last() == current.last())
return;

// Assign current overlay polygon to the new object
QPolygonF polygon = mOverlayPolygonObject->polygon();
mNewMapObjectItem->setPolygon(polygon);
mNewMapObjectItem->setPolygon(next);

// Add a new editable point to the overlay
polygon.append(polygon.last());
mOverlayPolygonItem->setPolygon(polygon);
next.append(next.last());
mOverlayPolygonItem->setPolygon(next);
}
break;
}
Expand Down

0 comments on commit 058c752

Please sign in to comment.