The QQmlTypeLoader was deleted (and its thread shut down) when
the QQmlEnginePrivate was destroyed. However, the QQmlTypeLoader
runs a thread which would happiliy make calls on the engine and
its managed data. Fix this by stopping the QQmlTypeLoader's
thread right away in QQmlEngine.
Task-number: QTBUG-39905
Change-Id: Ida8e95d083f79237c74b036fd3521133a9fa4ac7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
if (d->isDebugging)
QQmlDebugServer::instance()->removeEngine(this);
+ d->typeLoader.invalidate();
+
// Emit onDestruction signals for the root context before
// we destroy the contexts, engine, Singleton Types etc. that
// may be required to handle the destruction signal.
/*! \internal */
QQmlDataLoader::~QQmlDataLoader()
{
+ invalidate();
+}
+
+void QQmlDataLoader::invalidate()
+{
for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
(*iter)->release();
+ m_networkReplies.clear();
- shutdownThread();
- delete m_thread;
+ if (m_thread) {
+ shutdownThread();
+ delete m_thread;
+ m_thread = 0;
+ }
}
void QQmlDataLoader::lock()
void QQmlDataLoader::shutdownThread()
{
- if (!m_thread->isShutdown())
+ if (m_thread && !m_thread->isShutdown())
m_thread->shutdown();
}
QQmlEngine *engine() const;
void initializeEngine(QQmlExtensionInterface *, const char *);
+ void invalidate();
protected:
void shutdownThread();