Skip to content

Commit

Permalink
qgscompoundcurve: Remove uneeded clearCache call in operator=
Browse files Browse the repository at this point in the history
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 04b1dd7)
  • Loading branch information
ptitjano authored and nyalldawson committed Oct 16, 2024
1 parent a1ffc18 commit 4e4a3e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/geometry/qgscompoundcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
7 changes: 7 additions & 0 deletions tests/src/core/geometry/testqgscompoundcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit 4e4a3e4

Please sign in to comment.