From ee4383c1bef1eb51ab52b0da9db098c4b8c9c7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 23 Apr 2018 09:53:19 +0200 Subject: wasm: make no-tread platform independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QT_NO_THREAD instead of Q_OS_HTML. This way we can test the no-thread config also on host builds. Move the render loop loopType override to after applying platform and environment settings, so that we don’t enable the threaded render loop by accident. Allow the windows render loop (whether or not this works is untested). Change-Id: I4ea76f386a3914de208a380663c665f962cd2069 Reviewed-by: Lorn Potter --- src/qml/qml/ftw/qqmlthread.cpp | 6 +++--- src/qml/qml/qqmltypeloader.cpp | 8 ++++---- src/quick/scenegraph/qsgrenderloop.cpp | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp index 322d3281c7..a36a599f24 100644 --- a/src/qml/qml/ftw/qqmlthread.cpp +++ b/src/qml/qml/ftw/qqmlthread.cpp @@ -323,14 +323,14 @@ void QQmlThread::internalCallMethodInThread(Message *message) bool wasEmpty = d->threadList.isEmpty(); d->threadList.append(message); -#ifdef Q_OS_HTML5 +#ifdef QT_NO_THREAD d->mainSync = message; #endif if (wasEmpty && d->m_threadProcessing == false) d->triggerThreadEvent(); -#ifndef Q_OS_HTML5 +#ifndef QT_NO_THREAD d->m_mainThreadWaiting = true; do { if (d->mainSync) { @@ -407,7 +407,7 @@ void QQmlThread::waitForNextMessage() d->lock(); Q_ASSERT(d->m_mainThreadWaiting == false); -#ifdef Q_OS_HTML5 +#ifdef QT_NO_THREAD d->triggerThreadEvent(); #endif d->m_mainThreadWaiting = true; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 5212b49670..81bda2c3bb 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1015,7 +1015,7 @@ struct StaticLoader { void loadThread(QQmlTypeLoader *loader, QQmlDataBlob *blob) const { -#ifdef Q_OS_HTML5 +#ifdef QT_NO_THREAD loader->m_thread->loadWithStaticDataAsync(blob, data); return; #else @@ -1057,7 +1057,7 @@ void QQmlTypeLoader::doLoad(const Loader &loader, QQmlDataBlob *blob, Mode mode) qWarning("QQmlTypeLoader::doLoad(%s): %s thread", qPrintable(blob->urlString()), m_thread->isThisThread()?"Compile":"Engine"); #endif -#ifdef Q_OS_HTML5 +#ifdef QT_NO_THREAD mode = Asynchronous; #endif if (m_thread->isThisThread()) { @@ -1692,7 +1692,7 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) } else if ((mode == PreferSynchronous || mode == Synchronous) && QQmlFile::isSynchronous(url)) { // this was started Asynchronous, but we need to force Synchronous // completion now (if at all possible with this type of URL). -#ifndef Q_OS_HTML5 +#ifndef QT_NO_THREAD if (!m_thread->isThisThread()) { // this only works when called directly from the UI thread, but not // when recursively called on the QML thread via resolveTypes() @@ -1717,7 +1717,7 @@ QQmlTypeData will not be cached. */ QQmlTypeData *QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url, Mode mode) { -#ifdef Q_OS_HTML5 +#ifdef QT_NO_THREAD mode = Asynchronous; #endif LockHolder holder(this); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index a55b7b4ad9..88b9c93448 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -201,12 +201,9 @@ QSGRenderLoop *QSGRenderLoop::instance() loopType = ThreadedRenderLoop; else loopType = WindowsRenderLoop; -#elif defined(Q_OS_HTML5) - loopType = BasicRenderLoop; -#else +#endif if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)) loopType = ThreadedRenderLoop; -#endif if (qmlNoThreadedRenderer()) loopType = BasicRenderLoop; @@ -223,6 +220,11 @@ QSGRenderLoop *QSGRenderLoop::instance() loopType = ThreadedRenderLoop; } +#ifdef QT_NO_THREAD + if (loopType == ThreadedRenderLoop) + loopType = BasicRenderLoop; +#endif + switch (loopType) { case ThreadedRenderLoop: qCDebug(QSG_LOG_INFO, "threaded render loop"); -- cgit v1.2.3