Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #59092 Remove duplicate equality operator for QgsPointXY #59096

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/PyQt6/core/auto_generated/qgspointxy.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Compares this point with another point with a fuzzy tolerance using distance com
.. versionadded:: 3.36
%End

bool operator==( const QgsPointXY &other ) /HoldGIL/;
bool operator==( const QgsPointXY &other ) const /HoldGIL/;

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

Expand Down Expand Up @@ -310,7 +310,6 @@ Multiply x and y by the given value




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
3 changes: 1 addition & 2 deletions python/core/auto_generated/qgspointxy.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Compares this point with another point with a fuzzy tolerance
.. versionadded:: 2.9
%End

bool operator==( const QgsPointXY &other ) /HoldGIL/;
bool operator==( const QgsPointXY &other ) const /HoldGIL/;

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

Expand Down Expand Up @@ -294,7 +294,6 @@ Multiply x and y by the given value




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
22 changes: 1 addition & 21 deletions src/core/qgspointxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class CORE_EXPORT QgsPointXY
}

//! equality operator
bool operator==( const QgsPointXY &other ) SIP_HOLDGIL
bool operator==( const QgsPointXY &other ) const SIP_HOLDGIL
{
if ( isEmpty() && other.isEmpty() )
return true;
Expand Down Expand Up @@ -400,26 +400,6 @@ class CORE_EXPORT QgsPointXY

Q_DECLARE_METATYPE( QgsPointXY )

inline bool operator==( const QgsPointXY &p1, const QgsPointXY &p2 ) SIP_SKIP
{
const bool nan1X = std::isnan( p1.x() );
const bool nan2X = std::isnan( p2.x() );
if ( nan1X != nan2X )
return false;
if ( !nan1X && !qgsDoubleNear( p1.x(), p2.x(), 1E-8 ) )
return false;

const bool nan1Y = std::isnan( p1.y() );
const bool nan2Y = std::isnan( p2.y() );
if ( nan1Y != nan2Y )
return false;

if ( !nan1Y && !qgsDoubleNear( p1.y(), p2.y(), 1E-8 ) )
return false;

return true;
}

inline std::ostream &operator << ( std::ostream &os, const QgsPointXY &p ) SIP_SKIP
{
// Use Local8Bit for printouts
Expand Down
4 changes: 3 additions & 1 deletion src/gui/qgsadvanceddigitizingdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,9 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e )
mSnapMatch = context.snappingUtils->snapToMap( point, nullptr, true );
if ( mSnapMatch.layer() )
{
if ( ( ( mSnapMatch.hasVertex() || mSnapMatch.hasLineEndpoint() ) && ( point == mSnapMatch.point() ) )
// note ND: I'm not 100% sure if the point == mSnapMatch.point() comparison was intended be done using QgsPointXY or QgsPoint objects here!
// I'm using QgsPointXY here to keep the behavior the same from before a duplicate QgsPointXY == operator was removed...
if ( ( ( mSnapMatch.hasVertex() || mSnapMatch.hasLineEndpoint() ) && ( QgsPointXY( point ) == mSnapMatch.point() ) )
|| ( mSnapMatch.hasEdge() && QgsProject::instance()->topologicalEditing() ) )
{
e->snapPoint();
Expand Down
Loading