summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-09-26 11:10:27 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-09-27 12:50:53 +0000
commita286529cbe2ae51e6bf19aaea4203afd6b4884de (patch)
tree10fffea1dbd9d99a8b2f2d84d9c22f5cc7fb6db9
parent8f2ced29ceedacd2f23f19af1813a5f351b43eec (diff)
Ensure meshName gets used in the functor
Change-Id: I9015546607b5663f1feada64bc03cb73d3538ef2 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
-rw-r--r--src/render/geometry/qmesh.cpp6
-rw-r--r--tests/auto/render/meshfunctors/tst_meshfunctors.cpp28
2 files changed, 32 insertions, 2 deletions
diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp
index 614806df0..cf14ff4ff 100644
--- a/src/render/geometry/qmesh.cpp
+++ b/src/render/geometry/qmesh.cpp
@@ -261,8 +261,10 @@ QGeometry *MeshFunctor::operator()()
bool MeshFunctor::operator ==(const QGeometryFactory &other) const
{
const MeshFunctor *otherFunctor = functor_cast<MeshFunctor>(&other);
- if (otherFunctor != nullptr)
- return (otherFunctor->m_sourcePath == m_sourcePath);
+ if (otherFunctor != nullptr) {
+ return (otherFunctor->m_sourcePath == m_sourcePath
+ && otherFunctor->m_meshName == m_meshName);
+ }
return false;
}
diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
index bf5f0d55f..e2877b24b 100644
--- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
+++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
@@ -27,8 +27,11 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <Qt3DCore/qcomponent.h>
#include <Qt3DRender/qgeometryfactory.h>
#include <Qt3DRender/qgeometry.h>
+#include <Qt3DRender/qmesh.h>
+#include <Qt3DRender/private/qmesh_p.h>
class MeshFunctorA : public Qt3DRender::QGeometryFactory
{
@@ -117,6 +120,31 @@ private Q_SLOTS:
QVERIFY(*functorB == *functorB);
QVERIFY(*functorASub == *functorASub);
}
+
+ void checkMeshFunctorEquality()
+ {
+ // GIVEN
+ const Qt3DRender::MeshFunctor functorA(QUrl::fromLocalFile(QLatin1String("/foo")),
+ QLatin1String("bar"));
+ const Qt3DRender::MeshFunctor functorB(QUrl::fromLocalFile(QLatin1String("/foo")),
+ QLatin1String("baz"));
+ const Qt3DRender::MeshFunctor functorC(QUrl::fromLocalFile(QLatin1String("/baz")),
+ QLatin1String("bar"));
+ const Qt3DRender::MeshFunctor functorD(QUrl::fromLocalFile(QLatin1String("/foo")),
+ QLatin1String("bar"));
+
+ // WHEN
+ const bool selfEquality = (functorA == functorA);
+ const bool sameSource = (functorA == functorB);
+ const bool sameMeshName = (functorA == functorC);
+ const bool perfectMatch = (functorA == functorD);
+
+ // THEN
+ QCOMPARE(selfEquality, true);
+ QCOMPARE(sameSource, false);
+ QCOMPARE(sameMeshName, false);
+ QCOMPARE(perfectMatch, true);
+ }
};
QTEST_APPLESS_MAIN(tst_MeshFunctors)