summaryrefslogtreecommitdiffstats
path: root/src/core/qpostman.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-03 17:08:08 +0200
committerSean Harmer <sean.harmer@kdab.com>2015-07-12 19:14:00 +0000
commit2b3f68d588c15830ebbacf55823b2af049d76b47 (patch)
treed4bbc39f0c19226f0adc67c4ad2131a4e460c170 /src/core/qpostman.cpp
parent6fcaef11f89994cfc9f117a07cb64b0e8959da2c (diff)
QChangeArbiter/QPostMan: batch frontend changes
- Updated unit tests - Added QAbstractPostman and QAbstractArbiter as they are more than QObserverInterfaces but still need to be easily testable. Change-Id: I0fc2ce48031eecc9bf893798650ef68e9d7d8bb7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/qpostman.cpp')
-rw-r--r--src/core/qpostman.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/qpostman.cpp b/src/core/qpostman.cpp
index bd91def10..b7e7904d7 100644
--- a/src/core/qpostman.cpp
+++ b/src/core/qpostman.cpp
@@ -39,6 +39,7 @@
#include <Qt3DCore/qscenepropertychange.h>
#include <Qt3DCore/qbackendscenepropertychange.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qlockableobserverinterface_p.h>
#include <Qt3DCore/qnode.h>
#include <Qt3DCore/private/qnode_p.h>
@@ -57,6 +58,7 @@ public:
Q_DECLARE_PUBLIC(QPostman)
QScene *m_scene;
+ std::vector<QSceneChangePtr> m_batch;
};
QPostman::QPostman(QObject *parent)
@@ -84,6 +86,23 @@ void QPostman::sceneChangeEvent(const QSceneChangePtr &e)
notifyFrontendNode.invoke(this, Q_ARG(QSceneChangePtr, e));
}
+/*!
+ * This will start or append \a change to a batch of changes from frontend
+ * nodes. Once the batch is complete, when the event loop returns, the batch is
+ * sent to the QChangeArbiter to notify the backend aspects.
+ */
+void QPostman::notifyBackend(const QSceneChangePtr &change)
+{
+ // If batch in progress
+ // add change
+ // otherwise start batch
+ // by calling a queued slot
+ Q_D(QPostman);
+ if (d->m_batch.empty())
+ QMetaObject::invokeMethod(this, "submitChangeBatch", Qt::QueuedConnection);
+ d->m_batch.push_back(change);
+}
+
void QPostman::notifyFrontendNode(const QSceneChangePtr &e)
{
Q_D(QPostman);
@@ -95,6 +114,16 @@ void QPostman::notifyFrontendNode(const QSceneChangePtr &e)
}
}
+void QPostman::submitChangeBatch()
+{
+ Q_D(QPostman);
+ QLockableObserverInterface *arbiter = Q_NULLPTR;
+ if (d->m_scene && (arbiter = d->m_scene->arbiter()) != Q_NULLPTR) {
+ arbiter->sceneChangeEventWithLock(d->m_batch);
+ d->m_batch.clear();
+ }
+}
+
} //Qt3D
QT_END_NAMESPACE