aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-06-09 09:14:54 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-06-09 09:19:34 +0200
commitd356a263f627b55424a9750163a00dffc6faebcf (patch)
treef448d6fb27e0b5fb911c0cec60cf2edac6a7e346
parent6a6242b30550b45180d74ddee82448cdf795eb21 (diff)
Support calling update while syncing scenegraph.
The variable inSync is written from the scene graph thread and read from the GUI thread, but this is safe as it is only written to during the sync phase, during which the GUI thread is already blocked.
-rw-r--r--src/declarative/items/qsgcanvas.cpp11
-rw-r--r--src/declarative/items/qsgcanvas_p.h2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp
index 240088cf23..e10c57d015 100644
--- a/src/declarative/items/qsgcanvas.cpp
+++ b/src/declarative/items/qsgcanvas.cpp
@@ -1792,7 +1792,14 @@ void QSGCanvas::maybeUpdate()
Q_D(QSGCanvas);
if (d->threadedRendering && d->thread && d->thread->isRunning()) {
- if (!d->renderThreadAwakened) {
+ Q_ASSERT_X(QThread::currentThread() == QApplication::instance()->thread() || d->thread->inSync,
+ "QSGCanvas::update",
+ "Function can only be called from GUI thread or during QSGItem::updatePaintNode()");
+
+ if (d->thread->inSync) {
+ d->thread->isExternalUpdatePending = true;
+
+ } else if (!d->renderThreadAwakened) {
#ifdef THREAD_DEBUG
printf("GUI: doing update...\n");
#endif
@@ -1899,7 +1906,9 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: Doing locked sync\n");
#endif
+ inSync = true;
d->syncSceneGraph();
+ inSync = false;
// Wake GUI after sync to let it continue animating and event processing.
wake();
diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h
index 9ea11f5892..7538b3d7c1 100644
--- a/src/declarative/items/qsgcanvas_p.h
+++ b/src/declarative/items/qsgcanvas_p.h
@@ -180,6 +180,7 @@ public:
, isRenderBlocked(false)
, isExternalUpdatePending(false)
, syncAlreadyHappened(false)
+ , inSync(false)
, doGrab(false)
, shouldExit(false)
, hasExited(false)
@@ -222,6 +223,7 @@ public:
uint isRenderBlocked : 1;
uint isExternalUpdatePending : 1;
uint syncAlreadyHappened : 1;
+ uint inSync : 1;
uint doGrab : 1;
uint shouldExit : 1;