diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2018-05-08 10:41:46 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2018-05-14 08:22:47 +0000 |
commit | 7e22af4bfdfd736e624321924eaae0e0d36940c7 (patch) | |
tree | b4f46f0ee995b2751022c4ddedb2822e106214c0 /src | |
parent | 809d305f938177cfb8488dc7fbfc28bc8eef9d20 (diff) |
webassembly: fix for crash and assert on no thread and wasm builds
This change requires moveToThread change in qtbase
Change-Id: Idf35af4b416f577dabb91f749929dbfe5c88a0f0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/layouts/qquicklayout.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/ftw/qqmlthread.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 16 | ||||
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 3 | ||||
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 15 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 3 |
6 files changed, 21 insertions, 39 deletions
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index b3a5a2cfc8..d2bf0bbe8f 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -781,7 +781,12 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) if (change == ItemChildAddedChange) { Q_D(QQuickLayout); QQuickItem *item = value.item; +#ifndef QT_NO_THREAD qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); +#else + // DirectConnection seems too quick for wasm here + QObject::connect(item, SIGNAL(baselineOffsetChanged(qreal)), this, SLOT(invalidateSenderItem())); +#endif QQuickItemPrivate::get(item)->addItemChangeListener(this, changeTypes); d->m_hasItemChangeListeners = true; if (isReady()) diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp index 9c44e18b87..cffa1b64b0 100644 --- a/src/qml/qml/ftw/qqmlthread.cpp +++ b/src/qml/qml/ftw/qqmlthread.cpp @@ -106,9 +106,6 @@ void QQmlThreadPrivate::triggerMainEvent() { Q_ASSERT(q->isThisThread()); QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User)); -#ifdef Q_OS_HTML5 - QCoreApplication::processEvents(); -#endif } // Trigger even in thread. Must be called from main thread. @@ -116,9 +113,6 @@ void QQmlThreadPrivate::triggerThreadEvent() { Q_ASSERT(!q->isThisThread()); QCoreApplication::postEvent(this, new QEvent(QEvent::User)); -#ifdef Q_OS_HTML5 - QCoreApplication::processEvents(); -#endif } bool QQmlThreadPrivate::MainObject::event(QEvent *e) @@ -329,14 +323,12 @@ void QQmlThread::internalCallMethodInThread(Message *message) bool wasEmpty = d->threadList.isEmpty(); d->threadList.append(message); -#ifdef QT_NO_THREAD - d->mainSync = message; -#endif if (wasEmpty && d->m_threadProcessing == false) d->triggerThreadEvent(); - -#ifndef QT_NO_THREAD +#ifdef QT_NO_THREAD + message->call(this); +#else d->m_mainThreadWaiting = true; do { if (d->mainSync) { @@ -412,10 +404,6 @@ void QQmlThread::waitForNextMessage() Q_ASSERT(!isThisThread()); d->lock(); Q_ASSERT(d->m_mainThreadWaiting == false); - -#ifdef QT_NO_THREAD - d->triggerThreadEvent(); -#endif d->m_mainThreadWaiting = true; if (d->mainSync || !d->threadList.isEmpty()) { if (d->mainSync) { diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index ed742c3681..1cab827b9f 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -495,9 +495,8 @@ The setError() method may only be called from within a QQmlDataBlob callback. */ void QQmlDataBlob::addDependency(QQmlDataBlob *blob) { -#ifndef Q_OS_HTML5 ASSERT_CALLBACK(); -#endif + Q_ASSERT(status() != Null); if (!blob || @@ -1005,12 +1004,7 @@ struct StaticLoader { void loadThread(QQmlTypeLoader *loader, QQmlDataBlob *blob) const { -#ifdef QT_NO_THREAD - loader->m_thread->loadWithStaticDataAsync(blob, data); - return; -#else loader->loadWithStaticDataThread(blob, data); -#endif } void load(QQmlTypeLoader *loader, QQmlDataBlob *blob) const { @@ -1047,9 +1041,6 @@ 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 QT_NO_THREAD - mode = Asynchronous; -#endif if (m_thread->isThisThread()) { unlock(); loader.loadThread(this, blob); @@ -1688,7 +1679,6 @@ 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 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() @@ -1699,7 +1689,6 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) lock(); } } -#endif } typeData->addref(); @@ -1713,9 +1702,6 @@ QQmlTypeData will not be cached. */ QQmlTypeData *QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url, Mode mode) { -#ifdef QT_NO_THREAD - mode = Asynchronous; -#endif LockHolder<QQmlTypeLoader> holder(this); QQmlTypeData *typeData = new QQmlTypeData(url, this); diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index cefe2de883..9c775f7e93 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -493,9 +493,6 @@ void QQuickFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExt data.inOvershoot = false; fixupMode = Normal; data.vTime = timeline.time(); -#ifdef Q_OS_HTML5 - QCoreApplication::processEvents(QEventLoop::EventLoopExec); -#endif } static bool fuzzyLessThanOrEqualTo(qreal a, qreal b) diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index f2e055e874..bc8163d53c 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -331,9 +331,18 @@ void QQuickItemView::setModel(const QVariant &m) if (d->model) { d->bufferMode = QQuickItemViewPrivate::BufferBefore | QQuickItemViewPrivate::BufferAfter; - connect(d->model, SIGNAL(createdItem(int,QObject*)), this, SLOT(createdItem(int,QObject*))); - connect(d->model, SIGNAL(initItem(int,QObject*)), this, SLOT(initItem(int,QObject*))); - connect(d->model, SIGNAL(destroyingItem(QObject*)), this, SLOT(destroyingItem(QObject*))); + + Qt::ConnectionType type = Qt::AutoConnection; +#ifdef QT_NO_THREAD + // This is needed because the thread affinity of the receiving object + // will be different from the executing thread, when threads are not + // supported + type = Qt::DirectConnection; +#endif + QObject::connect(d->model, SIGNAL(createdItem(int,QObject*)), this, SLOT(createdItem(int,QObject*)), type); + QObject::connect(d->model, SIGNAL(initItem(int,QObject*)), this, SLOT(initItem(int,QObject*)), type); + QObject::connect(d->model, SIGNAL(destroyingItem(QObject*)), this, SLOT(destroyingItem(QObject*)), type); + if (isComponentComplete()) { d->updateSectionCriteria(); d->refill(); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 3cdf851a8f..c126bcee0a 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -474,9 +474,6 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) // Might have been set during syncSceneGraph() if (data.updatePending) maybeUpdate(window); -#ifdef Q_OS_HTML5 - QCoreApplication::processEvents(QEventLoop::EventLoopExec); -#endif } void QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow *window) |