aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-03-15 17:08:21 +0100
committerJoni Poikelin <joni.poikelin@qt.io>2018-04-10 07:08:02 +0000
commit67b091c49cafb607db9756333aaa7229817f7348 (patch)
tree28b0426e5a8b79c20174394dbc68ef7fdd6ce31b /src/qml/qml/qqmltypeloader_p.h
parent2597e43497aa8a223d65c669f07bd2e8fdf7e1f1 (diff)
Fix crash when calling QQmlEngine::clearComponentCache()
We must protect various resources in the type loader with our existing lock. The QQmlTypeLoaderQmldirContent is now value based, so that we can release the lock on the shared cache early. Copying it involves adjusting the refcount of the QHash and QString instances in the QQmlDirParser. The safety of this was verified with a TSAN build and the example supplied in the task. It crashed reliably with TASN errors first and with this patch it runs without errors. Task-number: QTBUG-41465 Change-Id: I616843c4b8bdfd65d1277d4faa8cb884d8e77df8 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit a3ad52526f79c1528f170c8affe5af00b68ca61d)
Diffstat (limited to 'src/qml/qml/qqmltypeloader_p.h')
-rw-r--r--src/qml/qml/qqmltypeloader_p.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index ab32bac7b2..71bd5a8a7f 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -228,12 +228,16 @@ class QQmlTypeLoaderQmldirContent
{
private:
friend class QQmlTypeLoader;
- QQmlTypeLoaderQmldirContent();
void setContent(const QString &location, const QString &content);
void setError(const QQmlError &);
public:
+ QQmlTypeLoaderQmldirContent();
+ QQmlTypeLoaderQmldirContent(const QQmlTypeLoaderQmldirContent &) = default;
+ QQmlTypeLoaderQmldirContent &operator=(const QQmlTypeLoaderQmldirContent &) = default;
+
+ bool hasContent() const { return m_hasContent; }
bool hasError() const;
QList<QQmlError> errors(const QString &uri) const;
@@ -250,6 +254,7 @@ public:
private:
QQmlDirParser m_parser;
QString m_location;
+ bool m_hasContent = false;
};
class Q_QML_PRIVATE_EXPORT QQmlTypeLoader
@@ -304,7 +309,7 @@ public:
QString absoluteFilePath(const QString &path);
bool directoryExists(const QString &path);
- const QQmlTypeLoaderQmldirContent *qmldirContent(const QString &filePath);
+ const QQmlTypeLoaderQmldirContent qmldirContent(const QString &filePath);
void setQmldirContent(const QString &filePath, const QString &content);
void clearCache();