From ddf33a57ca714dab4862c66560f37c0e7b332293 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sat, 11 May 2024 13:19:11 +0700 Subject: [PATCH] Properly restore a polygon geometry rubber band (fixes #5235) --- src/core/rubberbandmodel.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/rubberbandmodel.cpp b/src/core/rubberbandmodel.cpp index 8c5106201d..80c229ee42 100644 --- a/src/core/rubberbandmodel.cpp +++ b/src/core/rubberbandmodel.cpp @@ -344,15 +344,15 @@ void RubberbandModel::setDataFromGeometry( QgsGeometry geometry, const QgsCoordi { break; } - - // skip last vertex on polygon, as it's duplicate of the last one - if ( geometry.type() == Qgis::GeometryType::Polygon && vertexId.vertex == abstractGeom->vertexCount() ) - { - continue; - } - mPointList << pt; } + + // for polygons, remove the last vertex which is a duplicate of the first vertex + if ( geometry.type() == Qgis::GeometryType::Polygon ) + { + mPointList.removeLast(); + } + // insert the last point twice so the resutling rubberband's current coordinate property being modified (by e.g. // the GNSS position) will not replace the last vertex from the passed geometry mPointList << mPointList.last();