aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2019-05-07 14:23:52 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2019-05-08 07:18:36 +0000
commitd70e57c1286e7b0bd4caeecdeb62a22e9098095c (patch)
treee5c297a6719d10f86c2a354dd213ede9399ef446 /src
parentbb882f433b6cf6fca56049df6b654fb6a39a7cab (diff)
Make QQmlThread work for no-thread debug mode
Disable isThisThread asserts: there is only going to be one thread. Add a no-thread implementation for internalCalMethodInMain(), which calls the message immediately, similar to the current internalCallMethodInThread() implementation. Change-Id: I554cacf572b5f47c9921d247773cc3d9127b8203 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 2ef1dc7e93..e961ed3d0d 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -104,14 +104,18 @@ QQmlThreadPrivate::MainObject::MainObject(QQmlThreadPrivate *p)
// Trigger mainEvent in main thread. Must be called from thread.
void QQmlThreadPrivate::triggerMainEvent()
{
+#if QT_CONFIG(thread)
Q_ASSERT(q->isThisThread());
+#endif
QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User));
}
// Trigger even in thread. Must be called from main thread.
void QQmlThreadPrivate::triggerThreadEvent()
{
+#if QT_CONFIG(thread)
Q_ASSERT(!q->isThisThread());
+#endif
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
@@ -353,6 +357,12 @@ void QQmlThread::internalCallMethodInThread(Message *message)
void QQmlThread::internalCallMethodInMain(Message *message)
{
+#if !QT_CONFIG(thread)
+ message->call(this);
+ delete message;
+ return;
+#endif
+
Q_ASSERT(isThisThread());
d->lock();
@@ -397,7 +407,9 @@ void QQmlThread::internalPostMethodToThread(Message *message)
void QQmlThread::internalPostMethodToMain(Message *message)
{
+#if QT_CONFIG(thread)
Q_ASSERT(isThisThread());
+#endif
d->lock();
bool wasEmpty = d->mainList.isEmpty();
d->mainList.append(message);
@@ -408,7 +420,9 @@ void QQmlThread::internalPostMethodToMain(Message *message)
void QQmlThread::waitForNextMessage()
{
+#if QT_CONFIG(thread)
Q_ASSERT(!isThisThread());
+#endif
d->lock();
Q_ASSERT(d->m_mainThreadWaiting == false);