summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-11-16 14:43:51 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-11-18 20:43:32 +0100
commitfdba23fe5ed5eb87a6bab7bc16d04b7e240a4d7e (patch)
treed40a14ea2bc56ee84fe5f988f75960e11bec2f5d
parenta3b3cf04271cdc98af947823aa005a8090a1d37a (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>
-rw-r--r--src/render/geometry/qgeometryfactory.h4
-rw-r--r--src/render/geometry/qmesh.cpp2
-rw-r--r--src/render/geometry/qmesh_p.h2
-rw-r--r--tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp2
-rw-r--r--tests/auto/render/meshfunctors/tst_meshfunctors.cpp6
-rw-r--r--tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp2
6 files changed, 10 insertions, 8 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)
diff --git a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp
index 19df24680..6026a3ff2 100644
--- a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp
+++ b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp
@@ -50,7 +50,7 @@ public:
return nullptr;
}
- bool operator ==(const Qt3DRender::QGeometryFactory &other) const final
+ bool equals(const Qt3DRender::QGeometryFactory &other) const final
{
const TestFactory *otherFactory = Qt3DRender::functor_cast<TestFactory>(&other);
if (otherFactory != nullptr)
diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
index f8110085b..f845f39c8 100644
--- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
+++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
@@ -52,7 +52,7 @@ public:
return nullptr;
}
- bool operator ==(const Qt3DRender::QGeometryFactory &other) const override
+ bool equals(const Qt3DRender::QGeometryFactory &other) const override
{
return Qt3DRender::functor_cast<MeshFunctorA>(&other);
}
@@ -74,7 +74,7 @@ public:
return nullptr;
}
- bool operator ==(const Qt3DRender::QGeometryFactory &other) const override
+ bool equals(const Qt3DRender::QGeometryFactory &other) const override
{
return Qt3DRender::functor_cast<MeshFunctorB>(&other);
}
@@ -91,7 +91,7 @@ public:
~MeshFunctorASub()
{}
- bool operator ==(const Qt3DRender::QGeometryFactory &other) const override
+ bool equals(const Qt3DRender::QGeometryFactory &other) const override
{
return Qt3DRender::functor_cast<MeshFunctorASub>(&other);
}
diff --git a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
index 8cfbc0d23..8addfe9ad 100644
--- a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
+++ b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
@@ -56,7 +56,7 @@ public:
return nullptr;
}
- bool operator ==(const Qt3DRender::QGeometryFactory &other) const final
+ bool equals(const Qt3DRender::QGeometryFactory &other) const final
{
const TestFactory *otherFactory = Qt3DRender::functor_cast<TestFactory>(&other);
if (otherFactory != nullptr)