From 4e4a3e4d2893c67bdc5c553d3069254bad8e68da Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Thu, 5 Sep 2024 19:51:26 +0200 Subject: [PATCH] qgscompoundcurve: Remove uneeded clearCache call in operator= Indeed `QgsCurve::operator=()` is already called. As, `QgsCurve` does not override `operator=`, `QgsAbstractGeometry::operator=()` is called. This operator calls the `clear()` method which already clears the cache and the existing curves. (cherry picked from commit 04b1dd7fcf71b5775932db8ed9d7c29220c1b242) --- src/core/geometry/qgscompoundcurve.cpp | 2 +- tests/src/core/geometry/testqgscompoundcurve.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/geometry/qgscompoundcurve.cpp b/src/core/geometry/qgscompoundcurve.cpp index 83adc35835c9..7fcc2e1344da 100644 --- a/src/core/geometry/qgscompoundcurve.cpp +++ b/src/core/geometry/qgscompoundcurve.cpp @@ -119,11 +119,11 @@ QgsCompoundCurve::QgsCompoundCurve( const QgsCompoundCurve &curve ): QgsCurve( c } } +// cppcheck-suppress operatorEqVarError QgsCompoundCurve &QgsCompoundCurve::operator=( const QgsCompoundCurve &curve ) { if ( &curve != this ) { - clearCache(); QgsCurve::operator=( curve ); for ( const QgsCurve *c : curve.mCurves ) { diff --git a/tests/src/core/geometry/testqgscompoundcurve.cpp b/tests/src/core/geometry/testqgscompoundcurve.cpp index 25f44dcb69db..72184bf75d5f 100644 --- a/tests/src/core/geometry/testqgscompoundcurve.cpp +++ b/tests/src/core/geometry/testqgscompoundcurve.cpp @@ -619,6 +619,13 @@ void TestQgsCompoundCurve::assignment() QVERIFY( cc1 != cc2 ); + QgsLineString ls2; + ls2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 3, 4, 5, 6 ) + << QgsPoint( Qgis::WkbType::PointM, 1 / 2.0, 5 / 7.0, 1, 3 ) + << QgsPoint( Qgis::WkbType::PointM, 2, 3, 5, 7 ) ); + cc2.addCurve( ls2.clone() ); + QVERIFY( cc1 != cc2 ); + cc2 = cc1; QCOMPARE( cc1, cc2 ); }