diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-09-04 18:21:41 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2017-09-07 07:53:36 +0000 |
commit | cf3b1bbd9ee048a28b58a55d76504b1c01e34811 (patch) | |
tree | 920fdef22725390389a8687bc3717c5e5220e32c /src/qml/qml/qqmltypeloader.cpp | |
parent | a8cff0a4dea4c5041854f9200b110e19af210a0f (diff) |
QmlProfiler: Avoid race conditions in QQmlTypeLoader
We have to make sure all profiler calls to one adapter are done from the
same thread.
It turns out that all the calls from QQmlTypeLoader are done from the
type loader thread. By using a separate adapter for that, we avoid any
extra locking.
Task-number: QTBUG-62987
Change-Id: Ice400b1c3b7bd920d855ceb1ba0d46417f50348d
(cherry picked from commit 4578a92744d447222f5e22851433d5dbecc51855)
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 6480420212..074f760a36 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -647,8 +647,7 @@ void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob) { Q_ASSERT(m_waitingFor.contains(blob)); Q_ASSERT(blob->status() == Error || blob->status() == Complete); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, - blob->url()); + QQmlCompilingProfiler prof(typeLoader()->profiler(), blob->url()); m_inCallback = true; @@ -901,6 +900,12 @@ void QQmlTypeLoader::invalidate() m_networkReplies.clear(); } +void QQmlTypeLoader::enableProfiler() +{ + Q_ASSERT(!m_profiler); + m_profiler = new QQmlProfiler; +} + void QQmlTypeLoader::lock() { m_thread->lock(); @@ -1216,7 +1221,7 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, QQmlFile *file) void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::Data &d) { QML_MEMORY_SCOPE_URL(blob->url()); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob->url()); + QQmlCompilingProfiler prof(profiler(), blob->url()); blob->m_inCallback = true; @@ -1236,7 +1241,7 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::Data &d) void QQmlTypeLoader::setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit) { QML_MEMORY_SCOPE_URL(blob->url()); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob->url()); + QQmlCompilingProfiler prof(profiler(), blob->url()); blob->m_inCallback = true; @@ -1594,6 +1599,9 @@ Constructs a new type loader that uses the given \a engine. */ QQmlTypeLoader::QQmlTypeLoader(QQmlEngine *engine) : m_engine(engine), m_thread(new QQmlTypeLoaderThread(this)), +#ifndef QT_NO_QML_DEBUGGER + m_profiler(0), +#endif m_typeCacheTrimThreshold(TYPELOADER_MINIMUM_TRIM_THRESHOLD) { } @@ -1610,6 +1618,10 @@ QQmlTypeLoader::~QQmlTypeLoader() clearCache(); invalidate(); + +#ifndef QT_NO_QML_DEBUGGER + delete m_profiler; +#endif } QQmlImportDatabase *QQmlTypeLoader::importDatabase() |