From 058c7523272ad84c27770ac7a15a8dd71420179c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Sun, 16 Oct 2011 01:04:52 +0200 Subject: [PATCH] Avoid creating multiple polygon points at the same location 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. --- src/tiled/createobjecttool.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tiled/createobjecttool.cpp b/src/tiled/createobjecttool.cpp index ec31c41323..d5b6f6b561 100644 --- a/src/tiled/createobjecttool.cpp +++ b/src/tiled/createobjecttool.cpp @@ -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; }