diff options
author | Marc Mutz <marc.mutz@qt.io> | 2021-11-16 14:43:51 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2021-11-18 20:43:32 +0100 |
commit | fdba23fe5ed5eb87a6bab7bc16d04b7e240a4d7e (patch) | |
tree | d40a14ea2bc56ee84fe5f988f75960e11bec2f5d /src/render | |
parent | a3b3cf04271cdc98af947823aa005a8090a1d37a (diff) |
QGeometryFactory: don't make op== virtual
That's too clever, and it backfires with compilation errors in C++20
mode:
qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:129:29: error: ambiguous overload for ‘operator==’ (operand types are ‘MeshFunctorA’ and ‘MeshFunctorB’)
129 | QVERIFY(!(*functorA == *functorB));
| ~~~~~~~~~ ^~ ~~~~~~~~~
| | |
| MeshFunctorA MeshFunctorB
qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:72:10: note: candidate: ‘virtual bool MeshFunctorB::operator==(const Qt3DCore::QGeometryFactory&) const’ (reversed)
72 | bool operator ==(const Qt3DCore::QGeometryFactory &other) const override
| ^~~~~~~~
qt3d/tests/auto/render/meshfunctors/tst_meshfunctors.cpp:50:10: note: candidate: ‘virtual bool MeshFunctorA::operator==(const Qt3DCore::QGeometryFactory&) const’
50 | bool operator ==(const Qt3DCore::QGeometryFactory &other) const override
| ^~~~~~~~
Fix by providing a symmetric operator== for QGeometryFactory that
delegates to a virtual equals() method.
Change-Id: I23d29ad1b16075629132f2b4757c5810d5615a36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
(cherry picked from commit ec291f9974ba6d25148955a0b9e55b30c589a9be)
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/geometry/qgeometryfactory.h | 4 | ||||
-rw-r--r-- | src/render/geometry/qmesh.cpp | 2 | ||||
-rw-r--r-- | src/render/geometry/qmesh_p.h | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/render/geometry/qgeometryfactory.h b/src/render/geometry/qgeometryfactory.h index c2a45ddbc..d82039568 100644 --- a/src/render/geometry/qgeometryfactory.h +++ b/src/render/geometry/qgeometryfactory.h @@ -55,7 +55,9 @@ class Q_3DRENDERSHARED_EXPORT QGeometryFactory : public QAbstractFunctor public: virtual ~QGeometryFactory(); virtual QGeometry *operator()() = 0; - virtual bool operator ==(const QGeometryFactory &other) const = 0; + virtual bool equals(const QGeometryFactory &other) const = 0; + friend bool operator==(const QGeometryFactory &lhs, const QGeometryFactory &rhs) + { return lhs.equals(rhs); } }; typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr; diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp index ecbdd47d2..a8950cca8 100644 --- a/src/render/geometry/qmesh.cpp +++ b/src/render/geometry/qmesh.cpp @@ -391,7 +391,7 @@ QGeometry *MeshLoaderFunctor::operator()() /*! * \internal */ -bool MeshLoaderFunctor::operator ==(const QGeometryFactory &other) const +bool MeshLoaderFunctor::equals(const QGeometryFactory &other) const { const MeshLoaderFunctor *otherFunctor = functor_cast<MeshLoaderFunctor>(&other); if (otherFunctor != nullptr) diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h index 9ea0935bb..60b4d4632 100644 --- a/src/render/geometry/qmesh_p.h +++ b/src/render/geometry/qmesh_p.h @@ -119,7 +119,7 @@ public : QMesh::Status status() const { return m_status; } QGeometry *operator()() override; - bool operator ==(const QGeometryFactory &other) const override; + bool equals(const QGeometryFactory &other) const override; QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QT3D_FUNCTOR(MeshLoaderFunctor) |