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 /tests/auto | |
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 'tests/auto')
3 files changed, 5 insertions, 5 deletions
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) |