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.
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
#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();
, isRenderBlocked(false)
, isExternalUpdatePending(false)
, syncAlreadyHappened(false)
+ , inSync(false)
, doGrab(false)
, shouldExit(false)
, hasExited(false)
uint isRenderBlocked : 1;
uint isExternalUpdatePending : 1;
uint syncAlreadyHappened : 1;
+ uint inSync : 1;
uint doGrab : 1;
uint shouldExit : 1;