aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2014-08-28 16:51:00 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2014-08-28 16:52:02 +0200
commite64b6245a91a9d2bd269452c772c7c6eea784b39 (patch)
tree7991c4cbfc7a0b702fef6b8a3e9cb362a2b9ce8b /src
parent26fb6a0915ec64d30eaa78e781e7f18468bc2ed7 (diff)
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 <Thomas.Hartmann@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/models/qmldir1
-rw-r--r--src/imports/qtquick2/qmldir1
-rw-r--r--src/imports/window/qmldir1
-rw-r--r--src/imports/xmllistmodel/qmldir1
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc22
-rw-r--r--src/qml/qml/qqmldirparser.cpp13
-rw-r--r--src/qml/qml/qqmldirparser_p.h2
-rw-r--r--src/qml/qml/qqmlimport.cpp16
-rw-r--r--src/qml/qml/qqmlimport_p.h2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp4
-rw-r--r--src/qml/qml/qqmltypeloader_p.h2
11 files changed, 64 insertions, 1 deletions
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::TypeInfo> 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<QString,Component> components() const;
QList<Script> scripts() const;
QList<Plugin> plugins() const;
+ bool designerSupported() const;
#ifdef QT_CREATOR
struct TypeInfo
@@ -144,6 +145,7 @@ private:
QHash<QString,Component> _components; // multi hash
QList<Script> _scripts;
QList<Plugin> _plugins;
+ bool _designerSupported;
#ifdef QT_CREATOR
QList<TypeInfo> _typeInfos;
#endif
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index da37b0a76e..141cd4acbf 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -64,6 +64,7 @@ static const QLatin1Char Colon(':');
static const QLatin1String Slash_qmldir("/qmldir");
static const QLatin1String String_qmldir("qmldir");
static const QString dotqml_string(QLatin1String(".qml"));
+static bool designerSupportRequired = false;
namespace {
@@ -881,6 +882,16 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
qDebug().nospace() << "QQmlImports(" << qPrintable(base) << ")::importExtension: "
<< "loaded " << qmldirFilePath;
+ if (designerSupportRequired && !qmldir->designerSupported()) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("module does not support the designer \"%1\"").arg(qmldir->typeNamespace()));
+ error.setUrl(QUrl::fromLocalFile(qmldirFilePath));
+ errors->prepend(error);
+ }
+ return false;
+ }
+
int qmldirPluginCount = qmldir->plugins().count();
if (qmldirPluginCount == 0)
return true;
@@ -1539,6 +1550,11 @@ bool QQmlImports::isLocal(const QUrl &url)
return QQmlFile::isBundle(url) || !QQmlFile::urlToLocalFileOrQrc(url).isEmpty();
}
+void QQmlImports::setDesignerSupportRequired(bool b)
+{
+ designerSupportRequired = b;
+}
+
/*!
\class QQmlImportDatabase
diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h
index de29318f60..26eab669bc 100644
--- a/src/qml/qml/qqmlimport_p.h
+++ b/src/qml/qml/qqmlimport_p.h
@@ -129,6 +129,8 @@ public:
static bool isLocal(const QString &url);
static bool isLocal(const QUrl &url);
+ static void setDesignerSupportRequired(bool b);
+
private:
friend class QQmlImportDatabase;
QQmlImportsPrivate *d;
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 6913019562..0b7cc8e911 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1571,6 +1571,10 @@ QString QQmlTypeLoader::QmldirContent::pluginLocation() const
return m_location;
}
+bool QQmlTypeLoader::QmldirContent::designerSupported() const
+{
+ return m_parser.designerSupported();
+}
/*!
Constructs a new type loader that uses the given \a engine.
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 3d3ad28091..9f98e4fd40 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -320,6 +320,8 @@ public:
QString pluginLocation() const;
+ bool designerSupported() const;
+
private:
QQmlDirParser m_parser;
QString m_location;