aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-09-15 16:57:35 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-09-16 09:40:03 +0200
commit2a6a33767f7068fc5c43bc03f66df6329fc3cea6 (patch)
tree17d7fc69e626e80eb519b1f8e5e59b3f7e1a4737 /src
parent0265eec3ae023acc46cd66d6966ec966fd4bdbf8 (diff)
Don't start QQmlThreads from their constructor
In the case of derived classes (like the only user of QQmlThread) we cannot guarantee that the class is completely constructed when the thread starts. This includes the vtable which is necessary to decide which virtual functions to call. Change-Id: Ieaea67a72cc3b4f845b8621b34ca2928185917fb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp15
-rw-r--r--src/qml/qml/ftw/qqmlthread_p.h2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 397b4851cf..18b257dc0e 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -207,12 +207,6 @@ void QQmlThreadPrivate::threadEvent()
QQmlThread::QQmlThread()
: d(new QQmlThreadPrivate(this))
{
- d->lock();
- d->start();
- d->wait();
- d->unlock();
- d->moveToThread(d);
-
}
QQmlThread::~QQmlThread()
@@ -220,6 +214,15 @@ QQmlThread::~QQmlThread()
delete d;
}
+void QQmlThread::startup()
+{
+ d->lock();
+ d->start();
+ d->wait();
+ d->unlock();
+ d->moveToThread(d);
+}
+
void QQmlThread::shutdown()
{
d->lock();
diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h
index 995fcd4824..95d32d4fd2 100644
--- a/src/qml/qml/ftw/qqmlthread_p.h
+++ b/src/qml/qml/ftw/qqmlthread_p.h
@@ -60,6 +60,8 @@ class QQmlThread
public:
QQmlThread();
virtual ~QQmlThread();
+
+ void startup();
void shutdown();
bool isShutdown() const;
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 0b7cc8e911..0e2d4d027a 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -728,6 +728,8 @@ void QQmlDataBlob::ThreadData::setProgress(quint8 v)
QQmlDataLoaderThread::QQmlDataLoaderThread(QQmlDataLoader *loader)
: m_loader(loader), m_networkAccessManager(0), m_networkReplyProxy(0)
{
+ // Do that after initializing all the members.
+ startup();
}
QNetworkAccessManager *QQmlDataLoaderThread::networkAccessManager() const