From e64b6245a91a9d2bd269452c772c7c6eea784b39 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 28 Aug 2014 16:51:00 +0200 Subject: Add new property "designersupported" to qmldir This patch adds a property called "designersupported" to qmldir. This allows the Qt Quick Designer to only load plugins that have the line ""designersupported"" in their qmldir file. So the designer can load sub components without risking to load plugins that have never been tested in the designer and that might crash. The check for "designersupported"" is activated by using QQmlImports::setDesignerSupportRequired(). Change-Id: I4bf07cc163faa47996eacb1365a7961c51c51060 Reviewed-by: Thomas Hartmann Reviewed-by: Tim Jenssen --- src/qml/qml/qqmldirparser.cpp | 13 ++++++++++++- src/qml/qml/qqmldirparser_p.h | 2 ++ src/qml/qml/qqmlimport.cpp | 16 ++++++++++++++++ src/qml/qml/qqmlimport_p.h | 2 ++ src/qml/qml/qqmltypeloader.cpp | 4 ++++ src/qml/qml/qqmltypeloader_p.h | 2 ++ 6 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 5f5f7d4a38..7068818f15 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -55,7 +55,7 @@ static int parseInt(const QStringRef &str, bool *ok) return number; } -QQmlDirParser::QQmlDirParser() +QQmlDirParser::QQmlDirParser() : _designerSupported(false) { } @@ -87,6 +87,7 @@ bool QQmlDirParser::parse(const QString &source) _plugins.clear(); _components.clear(); _scripts.clear(); + _designerSupported = false; quint16 lineNumber = 0; bool firstLine = true; @@ -225,6 +226,11 @@ bool QQmlDirParser::parse(const QString &source) _typeInfos.append(typeInfo); #endif + } else if (sections[0] == QLatin1String("designersupported")) { + if (sectionCount != 1) + reportError(lineNumber, 0, QString::fromLatin1("designersupported does not expect any argument")); + else + _designerSupported = true; } else if (sectionCount == 2) { // No version specified (should only be used for relative qmldir files) const Component entry(sections[0], sections[1], -1, -1); @@ -354,6 +360,11 @@ QList QQmlDirParser::typeInfos() const } #endif +bool QQmlDirParser::designerSupported() const +{ + return _designerSupported; +} + QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component) { const QString output = QString::fromLatin1("{%1 %2.%3}"). diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index faede99afd..54843a13b0 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -121,6 +121,7 @@ public: QHash components() const; QList