diff --git a/src/render/picking/qabstractraycaster.cpp b/src/render/picking/qabstractraycaster.cpp index 5f4c4c490..f26c67e99 100644 --- a/src/render/picking/qabstractraycaster.cpp +++ b/src/render/picking/qabstractraycaster.cpp @@ -337,11 +337,7 @@ void QAbstractRayCaster::addLayer(QLayer *layer) if (!layer->parent()) layer->setParent(this); - if (d->m_changeArbiter != nullptr) { - const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), layer); - change->setPropertyName("layer"); - d->notifyObservers(change); - } + d->updateNode(layer, "layer", Qt3DCore::PropertyValueAdded); } } @@ -352,11 +348,7 @@ void QAbstractRayCaster::removeLayer(QLayer *layer) { Q_ASSERT(layer); Q_D(QAbstractRayCaster); - if (d->m_changeArbiter != nullptr) { - const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), layer); - change->setPropertyName("layer"); - d->notifyObservers(change); - } + d->updateNode(layer, "layer", Qt3DCore::PropertyValueRemoved); d->m_layers.removeOne(layer); // Remove bookkeeping connection d->unregisterDestructionHelper(layer); diff --git a/tests/auto/render/qraycaster/tst_qraycaster.cpp b/tests/auto/render/qraycaster/tst_qraycaster.cpp index 720c372de..8ac084545 100644 --- a/tests/auto/render/qraycaster/tst_qraycaster.cpp +++ b/tests/auto/render/qraycaster/tst_qraycaster.cpp @@ -80,7 +80,7 @@ private Q_SLOTS: QScopedPointer rayCaster(new Qt3DRender::QRayCaster()); QVERIFY(!rayCaster->isEnabled()); - QVERIFY(rayCaster->direction().length() > 0.); + QVERIFY(rayCaster->direction().length() > 0.f); QCOMPARE(rayCaster->runMode(), Qt3DRender::QAbstractRayCaster::SingleShot); // WHEN @@ -125,13 +125,11 @@ private Q_SLOTS: QCoreApplication::processEvents(); // THEN - QCOMPARE(arbiter.events.size(), 1); - auto addChange = arbiter.events.first().staticCast(); - QCOMPARE(addChange->propertyName(), "layer"); - QCOMPARE(addChange->subjectId(), rayCaster->id()); - QCOMPARE(addChange->addedNodeId(), rayCaster->layers().at(0)->id()); - QCOMPARE(addChange->type(), Qt3DCore::PropertyValueAdded); + QCOMPARE(arbiter.events.size(), 0); + QCOMPARE(arbiter.dirtyNodes.size(), 1); + QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data()); + arbiter.dirtyNodes.clear(); arbiter.events.clear(); // WHEN @@ -141,13 +139,11 @@ private Q_SLOTS: QCoreApplication::processEvents(); // THEN - QCOMPARE(arbiter.events.size(), 1); - addChange = arbiter.events.first().staticCast(); - QCOMPARE(addChange->propertyName(), "layer"); - QCOMPARE(addChange->subjectId(), rayCaster->id()); - QCOMPARE(addChange->addedNodeId(), rayCaster->layers().at(1)->id()); - QCOMPARE(addChange->type(), Qt3DCore::PropertyValueAdded); + QCOMPARE(arbiter.events.size(), 0); + QCOMPARE(arbiter.dirtyNodes.size(), 1); + QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data()); + arbiter.dirtyNodes.clear(); arbiter.events.clear(); // WHEN @@ -156,13 +152,11 @@ private Q_SLOTS: QCoreApplication::processEvents(); // THEN - QCOMPARE(arbiter.events.size(), 1); - auto removeChange = arbiter.events.first().staticCast(); - QCOMPARE(removeChange->propertyName(), "layer"); - QCOMPARE(removeChange->subjectId(), rayCaster->id()); - QCOMPARE(removeChange->removedNodeId(), layer->id()); - QCOMPARE(removeChange->type(), Qt3DCore::PropertyValueRemoved); + QCOMPARE(arbiter.events.size(), 0); + QCOMPARE(arbiter.dirtyNodes.size(), 1); + QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data()); + arbiter.dirtyNodes.clear(); arbiter.events.clear(); } @@ -209,29 +203,6 @@ private Q_SLOTS: << QByteArray(SIGNAL(hitsChanged(const Hits &))) << QByteArrayLiteral("hits"); } - - void checkBackendUpdates() - { - // GIVEN - QFETCH(QByteArray, signalPrototype); - QFETCH(QByteArray, propertyName); - QScopedPointer rayCaster(new MyRayCaster()); - QSignalSpy spy(rayCaster.data(), signalPrototype.constData()); - Qt3DRender::QRayCaster::Hits hits; - - // WHEN - // Create Backend Change and distribute it to frontend node - Qt3DCore::QPropertyUpdatedChangePtr e(new Qt3DCore::QPropertyUpdatedChange(rayCaster->id())); - e->setPropertyName(propertyName.constData()); - QVariant v; - v.setValue(hits); - e->setValue(v); - rayCaster->sceneChangeEvent(e); - - // THEN - // Check that the QRayCaster triggers the expected signal - QCOMPARE(spy.count(), 1); - } }; QTEST_MAIN(tst_QRayCaster)