Commit aee3dbc8 authored by Paul Lemire's avatar Paul Lemire
Browse files

Buffer: mark as dirty even if empty on firstTime



We otherwise assert in the case we create an empty buffer
that is empty but referenced by Attributes.
This is still a valid case as buffer data can be set later
on.

Change-Id: Ida198f5815f6cbb488b6b27436c4238146c3ae39
Reviewed-by: Mike Krus's avatarMike Krus <mike.krus@kdab.com>
parent b71e3b7b
......@@ -130,8 +130,10 @@ void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
if (!node)
return;
if (firstTime && m_manager != nullptr)
if (firstTime && m_manager != nullptr) {
m_manager->addBufferReference(peerId());
m_bufferDirty = true;
}
m_syncData = node->isSyncData();
m_access = node->accessType();
......
......@@ -329,7 +329,7 @@ void QBuffer::setData(const QByteArray &bytes)
Q_D(QBuffer);
if (bytes != d->m_data) {
d->m_data = bytes;
Qt3DCore::QNodePrivate::get(this)->update();
d->update();
emit dataChanged(bytes);
}
}
......
......@@ -113,25 +113,39 @@ private Q_SLOTS:
// GIVEN
Qt3DRender::QBuffer frontendBuffer;
frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicCopy);
frontendBuffer.setData(QByteArrayLiteral("C7KR4"));
frontendBuffer.setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new TestFunctor(73)));
// WHEN
backendBuffer.setManager(&bufferManager);
backendBuffer.setRenderer(&renderer);
simulateInitializationSync(&frontendBuffer, &backendBuffer);
frontendBuffer.updateData(2, QByteArrayLiteral("LS5"));
// THEN
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::StaticDraw);
QVERIFY(backendBuffer.data().isEmpty());
QVERIFY(backendBuffer.dataGenerator().isNull());
QVERIFY(backendBuffer.pendingBufferUpdates().empty());
// WHEN
frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicCopy);
frontendBuffer.setData(QByteArrayLiteral("C7KR4"));
frontendBuffer.setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new TestFunctor(73)));
backendBuffer.syncFromFrontEnd(&frontendBuffer, false);
// THEN
QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::DynamicCopy);
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7LS5"));
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7KR4"));
QVERIFY(!backendBuffer.dataGenerator().isNull());
QVERIFY(!backendBuffer.pendingBufferUpdates().empty());
// WHEN
frontendBuffer.updateData(2, QByteArrayLiteral("LS5"));
backendBuffer.syncFromFrontEnd(&frontendBuffer, false);
// THEN
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7LS5"));
// WHEN
backendBuffer.cleanup();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment