From 7a310b1f813e3f3c2759c7b316ed9af30f57d5cd Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Thu, 28 Mar 2019 10:09:34 +0100 Subject: QChannelMapping: only send const char *propertyName to backend It was otherwise sending a QString property as well as the const char *propertyName. Given only propertyName is actually used, remove QString property from the backend to avoid useless confusion and stop sending the notification change. Change-Id: Ie26771e320e26d44d7fce3e0a864bad1d4df558f Reviewed-by: Mike Krus --- src/animation/backend/animationutils.cpp | 2 +- src/animation/backend/channelmapping.cpp | 5 ----- src/animation/backend/channelmapping_p.h | 4 ---- src/animation/frontend/qchannelmapping.cpp | 6 +++++- src/animation/frontend/qchannelmapping_p.h | 1 - .../animation/animationutils/tst_animationutils.cpp | 19 ------------------- .../animation/channelmapping/tst_channelmapping.cpp | 14 +------------- .../tst_findrunningclipanimatorsjob.cpp | 4 ---- .../animation/qchannelmapping/tst_qchannelmapping.cpp | 19 +++++-------------- 9 files changed, 12 insertions(+), 62 deletions(-) diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 17826e946..01484476d 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -526,7 +526,7 @@ QVector buildPropertyMappings(const QVector &chann if (mappingData.type == static_cast(QVariant::Invalid)) { qWarning() << "Unknown type for node id =" << mappingData.targetId - << "and property =" << mapping->property() + << "and property =" << mapping->propertyName() << "and callback =" << mapping->callback(); continue; } diff --git a/src/animation/backend/channelmapping.cpp b/src/animation/backend/channelmapping.cpp index d8572a074..2323182c6 100644 --- a/src/animation/backend/channelmapping.cpp +++ b/src/animation/backend/channelmapping.cpp @@ -53,7 +53,6 @@ ChannelMapping::ChannelMapping() : BackendNode(ReadOnly) , m_channelName() , m_targetId() - , m_property() , m_type(static_cast(QVariant::Invalid)) , m_componentCount(0) , m_propertyName(nullptr) @@ -73,7 +72,6 @@ void ChannelMapping::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePt const auto &data = typedChange->data; m_channelName = data.channelName; m_targetId = data.targetId; - m_property = data.property; m_type = data.type; m_componentCount = data.componentCount; m_propertyName = data.propertyName; @@ -107,7 +105,6 @@ void ChannelMapping::cleanup() setEnabled(false); m_channelName.clear(); m_targetId = Qt3DCore::QNodeId(); - m_property.clear(); m_type = static_cast(QVariant::Invalid); m_propertyName = nullptr; m_componentCount = 0; @@ -125,8 +122,6 @@ void ChannelMapping::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) m_channelName = change->value().toString(); else if (change->propertyName() == QByteArrayLiteral("target")) m_targetId = change->value().value(); - else if (change->propertyName() == QByteArrayLiteral("property")) - m_property = change->value().toString(); else if (change->propertyName() == QByteArrayLiteral("type")) m_type = change->value().toInt(); else if (change->propertyName() == QByteArrayLiteral("propertyName")) diff --git a/src/animation/backend/channelmapping_p.h b/src/animation/backend/channelmapping_p.h index 5159adae2..aa30e84ee 100644 --- a/src/animation/backend/channelmapping_p.h +++ b/src/animation/backend/channelmapping_p.h @@ -84,9 +84,6 @@ public: void setTargetId(Qt3DCore::QNodeId targetId) { m_targetId = targetId; } Qt3DCore::QNodeId targetId() const { return m_targetId; } - void setProperty(const QString &property) { m_property = property; } - QString property() const { return m_property; } - void setType(int type) { m_type = type; } int type() const { return m_type; } @@ -115,7 +112,6 @@ private: // Properties from QChannelMapping QString m_channelName; Qt3DCore::QNodeId m_targetId; - QString m_property; int m_type; int m_componentCount; const char *m_propertyName; diff --git a/src/animation/frontend/qchannelmapping.cpp b/src/animation/frontend/qchannelmapping.cpp index 0dbe68c8c..8f6ebe9ab 100644 --- a/src/animation/frontend/qchannelmapping.cpp +++ b/src/animation/frontend/qchannelmapping.cpp @@ -257,7 +257,12 @@ void QChannelMapping::setProperty(const QString &property) return; d->m_property = property; + + // The backend uses propertyName instead of property + const bool blocked = blockNotifications(true); emit propertyChanged(property); + blockNotifications(blocked); + d->updatePropertyNameTypeAndComponentCount(); } @@ -268,7 +273,6 @@ Qt3DCore::QNodeCreatedChangeBasePtr QChannelMapping::createNodeCreationChange() Q_D(const QChannelMapping); data.channelName = d->m_channelName; data.targetId = Qt3DCore::qIdForNode(d->m_target); - data.property = d->m_property; data.type = d->m_type; data.componentCount = d->m_componentCount; data.propertyName = d->m_propertyName; diff --git a/src/animation/frontend/qchannelmapping_p.h b/src/animation/frontend/qchannelmapping_p.h index 6a3f1afc5..0ab66a7f7 100644 --- a/src/animation/frontend/qchannelmapping_p.h +++ b/src/animation/frontend/qchannelmapping_p.h @@ -77,7 +77,6 @@ struct QChannelMappingData { QString channelName; Qt3DCore::QNodeId targetId; - QString property; int type; int componentCount; const char *propertyName; diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index 7a7abb1b3..36f1cbe2f 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -145,7 +145,6 @@ public: ChannelMapping *createChannelMapping(Handler *handler, const QString &channelName, const Qt3DCore::QNodeId targetId, - const QString &property, const char *propertyName, int type, int componentCount) @@ -155,7 +154,6 @@ public: setPeerId(channelMapping, channelMappingId); channelMapping->setHandler(handler); channelMapping->setTargetId(targetId); - channelMapping->setProperty(property); channelMapping->setPropertyName(propertyName); channelMapping->setChannelName(channelName); channelMapping->setType(type); @@ -292,7 +290,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -376,7 +373,6 @@ private Q_SLOTS: auto locationMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -384,7 +380,6 @@ private Q_SLOTS: auto metalnessMapping = createChannelMapping(handler, QLatin1String("Metalness"), Qt3DCore::QNodeId::createId(), - QLatin1String("metalness"), "metalness", static_cast(QVariant::Double), 1); @@ -392,7 +387,6 @@ private Q_SLOTS: auto baseColorMapping = createChannelMapping(handler, QLatin1String("BaseColor"), Qt3DCore::QNodeId::createId(), - QLatin1String("baseColor"), "baseColor", static_cast(QVariant::Vector3D), 3); @@ -400,7 +394,6 @@ private Q_SLOTS: auto roughnessMapping = createChannelMapping(handler, QLatin1String("Roughness"), Qt3DCore::QNodeId::createId(), - QLatin1String("roughness"), "roughness", static_cast(QVariant::Double), 1); @@ -408,7 +401,6 @@ private Q_SLOTS: auto rotationMapping = createChannelMapping(handler, QLatin1String("Rotation"), Qt3DCore::QNodeId::createId(), - QLatin1String("rotation"), "rotation", static_cast(QVariant::Quaternion), 4); @@ -416,7 +408,6 @@ private Q_SLOTS: auto morphTargetMapping = createChannelMapping(handler, QLatin1String("MorphTargetWeights"), Qt3DCore::QNodeId::createId(), - QLatin1String("weights"), "weights", static_cast(QVariant::List), 5); @@ -2558,7 +2549,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -2582,14 +2572,12 @@ private Q_SLOTS: auto channelMapping1 = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); auto channelMapping2 = createChannelMapping(handler, QLatin1String("Rotation"), Qt3DCore::QNodeId::createId(), - QLatin1String("rotatrion"), "rotation", static_cast(QVariant::Quaternion), 4); @@ -2621,28 +2609,24 @@ private Q_SLOTS: auto channelMapping1 = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); auto channelMapping2 = createChannelMapping(handler, QLatin1String("Rotation"), Qt3DCore::QNodeId::createId(), - QLatin1String("rotation"), "rotation", static_cast(QVariant::Quaternion), 4); auto channelMapping3 = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); auto channelMapping4 = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -3124,7 +3108,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -3141,7 +3124,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Rotation"), Qt3DCore::QNodeId::createId(), - QLatin1String("rotation"), "rotation", static_cast(QVariant::Quaternion), 4); @@ -3158,7 +3140,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Scale"), Qt3DCore::QNodeId::createId(), - QLatin1String("scale"), "scale", static_cast(QVariant::Vector3D), 3); diff --git a/tests/auto/animation/channelmapping/tst_channelmapping.cpp b/tests/auto/animation/channelmapping/tst_channelmapping.cpp index 5c04c7f89..35ffcb10a 100644 --- a/tests/auto/animation/channelmapping/tst_channelmapping.cpp +++ b/tests/auto/animation/channelmapping/tst_channelmapping.cpp @@ -79,7 +79,7 @@ private Q_SLOTS: QCOMPARE(backendMapping.isEnabled(), mapping.isEnabled()); QCOMPARE(backendMapping.channelName(), mapping.channelName()); QCOMPARE(backendMapping.targetId(), mapping.target()->id()); - QCOMPARE(backendMapping.property(), mapping.property()); + QVERIFY(qstrcmp(backendMapping.propertyName(), mapping.property().toLatin1().constData()) == 0); QVERIFY(qstrcmp(backendMapping.propertyName(), "foo") == 0); QCOMPARE(backendMapping.componentCount(), 2); QCOMPARE(backendMapping.type(), static_cast(QVariant::Vector2D)); @@ -114,7 +114,6 @@ private Q_SLOTS: QCOMPARE(backendMapping.isEnabled(), false); QCOMPARE(backendMapping.channelName(), QString()); QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId()); - QCOMPARE(backendMapping.property(), QString()); QCOMPARE(backendMapping.propertyName(), nullptr); QCOMPARE(backendMapping.componentCount(), 0); QCOMPARE(backendMapping.type(), static_cast(QVariant::Invalid)); @@ -137,7 +136,6 @@ private Q_SLOTS: QCOMPARE(backendMapping.isEnabled(), false); QCOMPARE(backendMapping.channelName(), QString()); QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId()); - QCOMPARE(backendMapping.property(), QString()); QCOMPARE(backendMapping.propertyName(), nullptr); QCOMPARE(backendMapping.componentCount(), 0); QCOMPARE(backendMapping.type(), static_cast(QVariant::Invalid)); @@ -182,16 +180,6 @@ private Q_SLOTS: // THEN QCOMPARE(backendMapping.targetId(), id); - // WHEN - const QString property(QLatin1String("bar")); - updateChange = QSharedPointer::create(Qt3DCore::QNodeId()); - updateChange->setPropertyName("property"); - updateChange->setValue(property); - backendMapping.sceneChangeEvent(updateChange); - - // THEN - QCOMPARE(backendMapping.property(), property); - // WHEN updateChange = QSharedPointer::create(Qt3DCore::QNodeId()); updateChange->setPropertyName("type"); diff --git a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp index cc09c7941..5d71b7dc6 100644 --- a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp +++ b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp @@ -59,7 +59,6 @@ public: ChannelMapping *createChannelMapping(Handler *handler, const QString &channelName, const Qt3DCore::QNodeId targetId, - const QString &property, const char *propertyName, int type, int componentCount) @@ -69,7 +68,6 @@ public: setPeerId(channelMapping, channelMappingId); channelMapping->setHandler(handler); channelMapping->setTargetId(targetId); - channelMapping->setProperty(property); channelMapping->setPropertyName(propertyName); channelMapping->setChannelName(channelName); channelMapping->setType(type); @@ -143,7 +141,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); @@ -189,7 +186,6 @@ private Q_SLOTS: auto channelMapping = createChannelMapping(handler, QLatin1String("Location"), Qt3DCore::QNodeId::createId(), - QLatin1String("translation"), "translation", static_cast(QVariant::Vector3D), 3); diff --git a/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp b/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp index 091876d09..a6e4e5eb8 100644 --- a/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp +++ b/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp @@ -202,7 +202,7 @@ private Q_SLOTS: QCOMPARE(creationChangeData->type(), Qt3DAnimation::QChannelMappingCreatedChangeBase::ChannelMapping); QCOMPARE(mapping.channelName(), data.channelName); QCOMPARE(mapping.target()->id(), data.targetId); - QCOMPARE(mapping.property(), data.property); + QVERIFY(qstrcmp(mapping.property().toLatin1().constData(), data.propertyName) == 0); QCOMPARE(data.type, static_cast(QVariant::Vector3D)); QCOMPARE(data.componentCount, 3); } @@ -229,7 +229,7 @@ private Q_SLOTS: QCOMPARE(creationChangeData->type(), Qt3DAnimation::QChannelMappingCreatedChangeBase::ChannelMapping); QCOMPARE(mapping.channelName(), data.channelName); QCOMPARE(mapping.target()->id(), data.targetId); - QCOMPARE(mapping.property(), data.property); + QVERIFY(qstrcmp(mapping.property().toLatin1().constData(), data.propertyName) == 0); QCOMPARE(data.type, static_cast(QVariant::Vector3D)); QCOMPARE(data.componentCount, 3); } @@ -294,13 +294,9 @@ private Q_SLOTS: QCoreApplication::processEvents(); // THEN - QCOMPARE(arbiter.events.size(), 4); - auto change = arbiter.events.takeFirst().staticCast(); - QCOMPARE(change->propertyName(), "property"); - QCOMPARE(change->type(), Qt3DCore::PropertyUpdated); - QCOMPARE(change->value().toString(), mapping.property()); + QCOMPARE(arbiter.events.size(), 3); - change = arbiter.events.takeFirst().staticCast(); + auto change = arbiter.events.takeFirst().staticCast(); QCOMPARE(change->propertyName(), "type"); QCOMPARE(change->type(), Qt3DCore::PropertyUpdated); QCOMPARE(change->value().toInt(), static_cast(QVariant::Vector3D)); @@ -367,7 +363,7 @@ private Q_SLOTS: QCoreApplication::processEvents(); // THEN - QCOMPARE(arbiter.events.size(), 5); + QCOMPARE(arbiter.events.size(), 4); // Automatic notification change when property is updated auto change = arbiter.events.takeFirst().staticCast(); @@ -375,11 +371,6 @@ private Q_SLOTS: QCOMPARE(change->type(), Qt3DCore::PropertyUpdated); QCOMPARE(change->value(), value); - change = arbiter.events.takeFirst().staticCast(); - QCOMPARE(change->propertyName(), "property"); - QCOMPARE(change->type(), Qt3DCore::PropertyUpdated); - QCOMPARE(change->value().toString(), mapping.property()); - change = arbiter.events.takeFirst().staticCast(); QCOMPARE(change->propertyName(), "type"); QCOMPARE(change->type(), Qt3DCore::PropertyUpdated); -- cgit v1.2.3