Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix hidden overloaded virtual warning
  • Loading branch information
nyalldawson committed Apr 9, 2023
1 parent 3342172 commit e456d5a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions python/core/auto_generated/geometry/qgstriangle.sip.in
Expand Up @@ -54,8 +54,10 @@ Construct a QgsTriangle from three QPointF.
:param p3: third point
%End

bool operator==( const QgsTriangle &other ) const /HoldGIL/;
bool operator!=( const QgsTriangle &other ) const /HoldGIL/;
virtual bool operator==( const QgsAbstractGeometry &other ) const /HoldGIL/;

virtual bool operator!=( const QgsAbstractGeometry &other ) const /HoldGIL/;


virtual QString geometryType() const /HoldGIL/;

Expand Down
19 changes: 11 additions & 8 deletions src/core/geometry/qgstriangle.cpp
Expand Up @@ -66,24 +66,27 @@ QgsTriangle::QgsTriangle( const QPointF p1, const QPointF p2, const QPointF p3 )
setExteriorRing( ext );
}

bool QgsTriangle::operator==( const QgsTriangle &other ) const
bool QgsTriangle::operator==( const QgsAbstractGeometry &other ) const
{
if ( isEmpty() && other.isEmpty() )
const QgsTriangle *otherTriangle = qgsgeometry_cast< const QgsTriangle * >( &other );
if ( !otherTriangle )
return false;

if ( isEmpty() && otherTriangle->isEmpty() )
{
return true;
}
else if ( isEmpty() || other.isEmpty() )
else if ( isEmpty() || otherTriangle->isEmpty() )
{
return false;
}

return ( ( vertexAt( 0 ) == other.vertexAt( 0 ) ) &&
( vertexAt( 1 ) == other.vertexAt( 1 ) ) &&
( vertexAt( 2 ) == other.vertexAt( 2 ) )
);
return ( ( vertexAt( 0 ) == otherTriangle->vertexAt( 0 ) ) &&
( vertexAt( 1 ) == otherTriangle->vertexAt( 1 ) ) &&
( vertexAt( 2 ) == otherTriangle->vertexAt( 2 ) ) );
}

bool QgsTriangle::operator!=( const QgsTriangle &other ) const
bool QgsTriangle::operator!=( const QgsAbstractGeometry &other ) const
{
return !operator==( other );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgstriangle.h
Expand Up @@ -63,8 +63,8 @@ class CORE_EXPORT QgsTriangle : public QgsPolygon
*/
explicit QgsTriangle( QPointF p1, QPointF p2, QPointF p3 ) SIP_HOLDGIL;

bool operator==( const QgsTriangle &other ) const SIP_HOLDGIL;
bool operator!=( const QgsTriangle &other ) const SIP_HOLDGIL;
bool operator==( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL;
bool operator!=( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL;

QString geometryType() const override SIP_HOLDGIL;
QgsTriangle *clone() const override SIP_FACTORY;
Expand Down

0 comments on commit e456d5a

Please sign in to comment.