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/imports/models/qmldir | 1 + src/imports/qtquick2/qmldir | 1 + src/imports/window/qmldir | 1 + src/imports/xmllistmodel/qmldir | 1 + src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc | 22 ++++++++++++++++++++++ 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 ++ 11 files changed, 64 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/models/qmldir b/src/imports/models/qmldir index 4afbe5de33..2dd20b923e 100644 --- a/src/imports/models/qmldir +++ b/src/imports/models/qmldir @@ -1,3 +1,4 @@ module QtQml.Models plugin modelsplugin classname QtQmlModelsPlugin +designersupported diff --git a/src/imports/qtquick2/qmldir b/src/imports/qtquick2/qmldir index 4a79c82e76..8167e813df 100644 --- a/src/imports/qtquick2/qmldir +++ b/src/imports/qtquick2/qmldir @@ -2,3 +2,4 @@ module QtQuick plugin qtquick2plugin classname QtQuick2Plugin typeinfo plugins.qmltypes +designersupported diff --git a/src/imports/window/qmldir b/src/imports/window/qmldir index c9d1e5ace3..fb6202b3bb 100644 --- a/src/imports/window/qmldir +++ b/src/imports/window/qmldir @@ -2,3 +2,4 @@ module QtQuick.Window plugin windowplugin classname QtQuick2WindowPlugin typeinfo plugins.qmltypes +designersupported diff --git a/src/imports/xmllistmodel/qmldir b/src/imports/xmllistmodel/qmldir index d6c10c5c2a..1f17dbb112 100644 --- a/src/imports/xmllistmodel/qmldir +++ b/src/imports/xmllistmodel/qmldir @@ -2,3 +2,4 @@ module QtQuick.XmlListModel plugin qmlxmllistmodelplugin classname QmlXmlListModelPlugin typeinfo plugins.qmltypes +designersupported diff --git a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc index ef6c8b1b67..a3ea25c005 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc +++ b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc @@ -221,6 +221,28 @@ typeinfo mymodule.qmltypes \code # this is a comment \endcode + + \row + \li designersupported + \li + \code + designersupported + \endcode + + \li Set this property if the plugin is supported by Qt Quick Designer. + By default, the plugin will not be supported. + + A plugin that is supported by Qt Quick Designer has to be properly + tested. This means that the plugin does not crash when running inside + the qml2puppet that is used by Qt Quick Designer to execute QML. + Generally the plugin should work well in the Qt Quick Designer + and not cause any show stoppers, like taking huge amounts of memory, + slowing down the qml2puppet heavily or anything else that renders + the plugin effectively unusable in the Qt Quick Designer. + + The items of an unsupported plugin are not painted in the Qt Quick Designer, + but they are still available as empty boxes and the properties can be edited. + \endtable Each command in a \c qmldir file must be on a separate line. 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