summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-03 15:14:19 +0200
committerSean Harmer <sean.harmer@kdab.com>2015-07-04 11:25:33 +0000
commita92ca8a4e74c805a2e870e3d184405c15c69f4a8 (patch)
tree365bcee464a99832ab1a3cc3997b395524835caf
parente5aea8e17dc6562933587d543b6a6aee5e6236af (diff)
QChangeArbiter/QLockableObserverInterface: sceneChangeEventWithLock overload
takes an std::vector<QSceneChangePtr> to soon allow efficient submission of change batches. Note: there's no real need for a similar overload of sceneChangeEvent yet. Change-Id: Id76eb77a0b6b2f1308a72d85d65948a3fb411951 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/core/qchangearbiter.cpp7
-rw-r--r--src/core/qchangearbiter_p.h1
-rw-r--r--src/core/qlockableobserverinterface_p.h3
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp7
-rw-r--r--tests/auto/core/qscene/tst_qscene.cpp1
5 files changed, 19 insertions, 0 deletions
diff --git a/src/core/qchangearbiter.cpp b/src/core/qchangearbiter.cpp
index 886b74036..6d84eebfd 100644
--- a/src/core/qchangearbiter.cpp
+++ b/src/core/qchangearbiter.cpp
@@ -260,6 +260,13 @@ void QChangeArbiter::sceneChangeEventWithLock(const QSceneChangePtr &e)
sceneChangeEvent(e);
}
+void QChangeArbiter::sceneChangeEventWithLock(const QSceneChangeList &e)
+{
+ QMutexLocker locker(&m_mutex);
+ QChangeQueue *localChangeQueue = m_tlsChangeQueue.localData();
+ localChangeQueue->insert(localChangeQueue->end(), e.begin(), e.end());
+}
+
// Either we have the postman or we could make the QChangeArbiter agnostic to the postman
// but that would require adding it to every QObserverList in m_aspectObservations.
void QChangeArbiter::setPostman(QObserverInterface *postman)
diff --git a/src/core/qchangearbiter_p.h b/src/core/qchangearbiter_p.h
index b18835e98..a2046caab 100644
--- a/src/core/qchangearbiter_p.h
+++ b/src/core/qchangearbiter_p.h
@@ -84,6 +84,7 @@ public:
void sceneChangeEvent(const QSceneChangePtr &e) Q_DECL_OVERRIDE; // QLockableObserverInterface impl
void sceneChangeEventWithLock(const QSceneChangePtr &e) Q_DECL_OVERRIDE; // QLockableObserverInterface impl
+ void sceneChangeEventWithLock(const QSceneChangeList &e) Q_DECL_OVERRIDE; // QLockableObserverInterface impl
Q_INVOKABLE void setPostman(Qt3D::QObserverInterface *postman);
Q_INVOKABLE void setScene(Qt3D::QSceneInterface *scene);
diff --git a/src/core/qlockableobserverinterface_p.h b/src/core/qlockableobserverinterface_p.h
index b0a64118a..088f3eda7 100644
--- a/src/core/qlockableobserverinterface_p.h
+++ b/src/core/qlockableobserverinterface_p.h
@@ -43,11 +43,14 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
+typedef std::vector<QSceneChangePtr> QSceneChangeList;
+
class QT3DCORESHARED_EXPORT QLockableObserverInterface : public QObserverInterface
{
public:
virtual ~QLockableObserverInterface();
virtual void sceneChangeEventWithLock(const QSceneChangePtr &e) = 0;
+ virtual void sceneChangeEventWithLock(const QSceneChangeList &e) = 0;
};
} // namespace Qt3D
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 05af6b615..d2248aa93 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -114,6 +114,13 @@ public:
events << ChangeRecord(e, true);
}
+ void sceneChangeEventWithLock(const Qt3D::QSceneChangeList &e) Q_DECL_OVERRIDE
+ {
+ for (uint i = 0, m = e.size(); i < m; ++i) {
+ events << ChangeRecord(e.at(i), false);
+ }
+ }
+
void sceneChangeEvent(const Qt3D::QSceneChangePtr &e) Q_DECL_OVERRIDE
{
events << ChangeRecord(e, false);
diff --git a/tests/auto/core/qscene/tst_qscene.cpp b/tests/auto/core/qscene/tst_qscene.cpp
index 51a469836..9c76b9eb6 100644
--- a/tests/auto/core/qscene/tst_qscene.cpp
+++ b/tests/auto/core/qscene/tst_qscene.cpp
@@ -66,6 +66,7 @@ class tst_LockableObserver : public Qt3D::QLockableObserverInterface
public:
void sceneChangeEvent(const Qt3D::QSceneChangePtr &) Q_DECL_OVERRIDE {}
void sceneChangeEventWithLock(const Qt3D::QSceneChangePtr &) Q_DECL_OVERRIDE {}
+ void sceneChangeEventWithLock(const Qt3D::QSceneChangeList &) Q_DECL_OVERRIDE {}
};
class tst_Observable : public Qt3D::QObservableInterface