summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-04-20 02:40:08 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-04-20 02:40:08 (GMT)
commitf31f7ee8e966f1ccb954c0bca614f5c5605c820f (patch)
treec6a60aa9df1aa6beff3a83d3f352578092604685
parentdc6414e75e2882dc0d23994ec8c5923906d8f08e (diff)
downloadQt-f31f7ee8e966f1ccb954c0bca614f5c5605c820f.zip
Qt-f31f7ee8e966f1ccb954c0bca614f5c5605c820f.tar.gz
Qt-f31f7ee8e966f1ccb954c0bca614f5c5605c820f.tar.bz2
Improve error messages, especially on embedded.
With embedded, it is often the case that some QT_NO_* features are turned off (eg. QT_NO_XMLPATTERNS), which in turn leads to QML types not being available.
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc55
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp20
-rw-r--r--src/declarative/qml/qdeclarative.h14
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp12
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp20
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h4
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp7
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h1
-rw-r--r--src/declarative/qml/qdeclarativetypenotavailable.cpp49
-rw-r--r--src/declarative/qml/qdeclarativetypenotavailable_p.h65
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp2
-rw-r--r--src/declarative/qml/qml.pri2
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp22
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tools/qml/qmlruntime.cpp2
19 files changed, 259 insertions, 26 deletions
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index b4d8a2e..a986fbc 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -79,7 +79,7 @@
\relates QDeclarativeEngine
This template function registers the C++ type in the QML system with
- the name \a qmlName. in the library imported from \a uri having the
+ the name \a qmlName, in the library imported from \a uri having the
version number composed from \a versionMajor and \a versionMinor.
Returns the QML type id.
@@ -94,6 +94,59 @@
*/
/*!
+ \fn int qmlRegisterTypeUncreatable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
+ \relates QDeclarativeEngine
+
+ This template function registers the C++ type in the QML system with
+ the name \a qmlName, in the library imported from \a uri having the
+ version number composed from \a versionMajor and \a versionMinor.
+
+ While the type has a name and a type, it cannot be created, and the
+ given error \a message will result if creation is attempted.
+
+ This is useful where the type is only intended for providing attached properties or enum values.
+
+ Returns the QML type id.
+
+ \sa qmlRegisterTypeNotAvailable
+*/
+
+/*!
+ \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
+ \relates QDeclarativeEngine
+
+ This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the
+ version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type
+ will produce the given error \a message.
+
+ Normally, the types exported by a module should be fixed. However, if a C++ type is not available, you should
+ at least "reserve" the QML type name, and give the user of your module a meaningful error message.
+
+ Returns the QML type id.
+
+ Example:
+
+ \code
+ #ifdef NO_GAMES_ALLOWED
+ qmlRegisterTypeNotAvailable("MinehuntCore", 0, 1, "Game", "Get back to work, slacker!");
+ #else
+ qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
+ #endif
+ \endcode
+
+ This will cause any QML which uses this module and attempts to use the type to produce an error message:
+ \code
+fun.qml: Get back to work, slacker!
+ Game {
+ ^
+ \endcode
+
+ Without this, a generic "Game is not a type" message would be given.
+
+ \sa qmlRegisterTypeUncreatable
+*/
+
+/*!
\fn int qmlRegisterType()
\relates QDeclarativeEngine
\overload
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 2d01eef..16972a8 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -82,7 +82,10 @@
void QDeclarativeItemModule::defineModule()
{
-#ifndef QT_NO_MOVIE
+#ifdef QT_NO_MOVIE
+ qmlRegisterTypeNotAvailable("Qt",4,6,"AnimatedImage",
+ qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie"));
+#else
qmlRegisterType<QDeclarativeAnimatedImage>("Qt",4,6,"AnimatedImage");
#endif
qmlRegisterType<QDeclarativeBorderImage>("Qt",4,6,"BorderImage");
@@ -141,17 +144,20 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QAction>();
qmlRegisterType<QDeclarativePen>();
qmlRegisterType<QDeclarativeFlickableVisibleArea>();
-#ifndef QT_NO_GRAPHICSEFFECT
+#ifdef QT_NO_GRAPHICSEFFECT
+ QString no_graphicseffect = qApp->translate("QGraphicsBlurEffect","Qt was built without support for graphicseffects");
+ qmlRegisterTypeNotAvailable("Qt",4,6,"Blur",no_graphicseffect);
+ qmlRegisterTypeNotAvailable("Qt",4,6,"Colorize",no_graphicseffect);
+ qmlRegisterTypeNotAvailable("Qt",4,6,"DropShadow",no_graphicseffect);
+ qmlRegisterTypeNotAvailable("Qt",4,6,"Opacity",no_graphicseffect);
+#else
qmlRegisterType<QGraphicsEffect>();
qmlRegisterType<QGraphicsBlurEffect>("Qt",4,6,"Blur");
qmlRegisterType<QGraphicsColorizeEffect>("Qt",4,6,"Colorize");
qmlRegisterType<QGraphicsDropShadowEffect>("Qt",4,6,"DropShadow");
qmlRegisterType<QGraphicsOpacityEffect>("Qt",4,6,"Opacity");
#endif
-#ifdef QT_WEBKIT_LIB
- qmlRegisterType<QDeclarativeWebSettings>();
-#endif
- qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("Qt",4,6,"KeyNavigation");
- qmlRegisterUncreatableType<QDeclarativeKeysAttached>("Qt",4,6,"Keys");
+ qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("Qt",4,6,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
+ qmlRegisterUncreatableType<QDeclarativeKeysAttached>("Qt",4,6,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties"));
}
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 6e36d4f..d75f0a8 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -100,6 +100,7 @@ int qmlRegisterType()
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
0, 0,
+ QString(),
0, 0, 0, 0, &T::staticMetaObject,
@@ -118,8 +119,10 @@ int qmlRegisterType()
return QDeclarativePrivate::registerType(type);
}
+int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
+
template<typename T>
-int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
{
QByteArray name(T::staticMetaObject.className());
@@ -132,6 +135,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
0, 0,
+ reason,
uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
@@ -164,6 +168,7 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
sizeof(T), QDeclarativePrivate::createInto<T>,
+ QString(),
uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
@@ -196,6 +201,7 @@ int qmlRegisterExtendedType()
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
0, 0,
+ QString(),
0, 0, 0, 0, &T::staticMetaObject,
@@ -236,6 +242,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
sizeof(T), QDeclarativePrivate::createInto<T>,
+ QString(),
uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
@@ -276,9 +283,9 @@ int qmlRegisterInterface(const char *typeName)
template<typename T>
int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
- const char *qmlName, const char *typeName, QDeclarativeCustomParser *parser)
+ const char *qmlName, QDeclarativeCustomParser *parser)
{
- QByteArray name(typeName);
+ QByteArray name(T::staticMetaObject.className());
QByteArray pointerName(name + '*');
QByteArray listName("QDeclarativeListProperty<" + name + ">");
@@ -289,6 +296,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
qRegisterMetaType<T *>(pointerName.constData()),
qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
sizeof(T), QDeclarativePrivate::createInto<T>,
+ QString(),
uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 2614764..10e4746 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -571,8 +571,12 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
QDeclarativeScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
if (tref.type) {
ref.type = tref.type;
- if (!ref.type->isCreatable())
- COMPILE_EXCEPTION(parserRef->refObjects.first(), tr( "Element is not creatable."));
+ if (!ref.type->isCreatable()) {
+ QString err = ref.type->noCreationReason();
+ if (err.isEmpty())
+ err = tr( "Element is not creatable.");
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), err);
+ }
} else if (tref.unit) {
ref.component = tref.unit->toComponent(engine);
@@ -864,12 +868,14 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
defaultProperty->release();
// Compile custom parser parts
- if (isCustomParser && !customProps.isEmpty()) {
+ if (isCustomParser/* && !customProps.isEmpty()*/) {
QDeclarativeCustomParser *cp = output->types.at(obj->type).type->customParser();
cp->clearErrors();
cp->compiler = this;
+ cp->object = obj;
obj->custom = cp->compile(customProps);
cp->compiler = 0;
+ cp->object = 0;
foreach (QDeclarativeError err, cp->errors()) {
err.setUrl(output->url);
exceptions << err;
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index 1a97315..472a883 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -89,6 +89,8 @@ using namespace QDeclarativeParser;
by \a data, which is a block of data previously returned by a call
to compile().
+ Errors should be reported using qmlInfo(object).
+
The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
*/
@@ -235,6 +237,24 @@ void QDeclarativeCustomParser::clearErrors()
}
/*!
+ Reports an error with the given \a description.
+
+ This can only be used during the compile() step. For errors during setCustomData(), use qmlInfo().
+
+ An error is generated referring to the position of the element in the source file.
+*/
+void QDeclarativeCustomParser::error(const QString& description)
+{
+ Q_ASSERT(object);
+ QDeclarativeError error;
+ QString exceptionDescription;
+ error.setLine(object->location.start.line);
+ error.setColumn(object->location.start.column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
Reports an error in parsing \a prop, with the given \a description.
An error is generated referring to the position of \a node in the source file.
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index da0358a..0e397c5 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -113,7 +113,7 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
{
public:
- QDeclarativeCustomParser() : compiler(0) {}
+ QDeclarativeCustomParser() : compiler(0), object(0) {}
virtual ~QDeclarativeCustomParser() {}
void clearErrors();
@@ -124,6 +124,7 @@ public:
QList<QDeclarativeError> errors() const { return exceptions; }
protected:
+ void error(const QString& description);
void error(const QDeclarativeCustomParserProperty&, const QString& description);
void error(const QDeclarativeCustomParserNode&, const QString& description);
@@ -132,6 +133,7 @@ protected:
private:
QList<QDeclarativeError> exceptions;
QDeclarativeCompiler *compiler;
+ QDeclarativeParser::Object *object;
friend class QDeclarativeCompiler;
};
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index 96bf4e5..8fee8a7 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -134,6 +134,7 @@ public:
int m_allocationSize;
void (*m_newFunc)(void *);
+ QString m_noCreationReason;
const QMetaObject *m_baseMetaObject;
QDeclarativeAttachedPropertiesFunc m_attachedPropertiesFunc;
@@ -186,6 +187,7 @@ QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::Registe
d->m_listId = type.listId;
d->m_allocationSize = type.objectSize;
d->m_newFunc = type.create;
+ d->m_noCreationReason = type.noCreationReason;
d->m_baseMetaObject = type.metaObject;
d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
@@ -389,6 +391,11 @@ QDeclarativeType::CreateFunc QDeclarativeType::createFunction() const
return d->m_newFunc;
}
+QString QDeclarativeType::noCreationReason() const
+{
+ return d->m_noCreationReason;
+}
+
int QDeclarativeType::createSize() const
{
return d->m_allocationSize;
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index 70b7c90..bf6a700 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -123,6 +123,7 @@ public:
bool isCreatable() const;
bool isExtendedType() const;
+ QString noCreationReason() const;
bool isInterface() const;
int typeId() const;
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index 6e240d8..e657dd5 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -184,6 +184,7 @@ namespace QDeclarativePrivate
int listId;
int objectSize;
void (*create)(void *);
+ QString noCreationReason;
const char *uri;
int versionMajor;
diff --git a/src/declarative/qml/qdeclarativetypenotavailable.cpp b/src/declarative/qml/qdeclarativetypenotavailable.cpp
new file mode 100644
index 0000000..7a84732
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenotavailable.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetypenotavailable_p.h"
+
+int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
+{
+ return qmlRegisterUncreatableType<QDeclarativeTypeNotAvailable>(uri,versionMajor,versionMinor,qmlName,message);
+}
+
+QDeclarativeTypeNotAvailable::QDeclarativeTypeNotAvailable() { }
diff --git a/src/declarative/qml/qdeclarativetypenotavailable_p.h b/src/declarative/qml/qdeclarativetypenotavailable_p.h
new file mode 100644
index 0000000..9c1c256
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenotavailable_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETYPENOTAVAILABLE_H
+#define QDECLARATIVETYPENOTAVAILABLE_H
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeTypeNotAvailable : public QObject {
+ Q_OBJECT
+public:
+ QDeclarativeTypeNotAvailable();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeTypeNotAvailable)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVETYPENOTAVAILABLE_H
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index c5f6d6a..d4bb8ee 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -59,6 +59,8 @@ int qmlRegisterValueTypeEnums(const char *qmlName)
qRegisterMetaType<T *>(pointerName.constData()), 0, 0, 0,
+ QString(),
+
"Qt", 4, 6, qmlName, &T::staticMetaObject,
0, 0,
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index c48662c..3848593 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -40,6 +40,7 @@ SOURCES += \
$$PWD/qdeclarativepropertycache.cpp \
$$PWD/qdeclarativenotifier.cpp \
$$PWD/qdeclarativeintegercache.cpp \
+ $$PWD/qdeclarativetypenotavailable.cpp \
$$PWD/qdeclarativetypenamecache.cpp \
$$PWD/qdeclarativescriptstring.cpp \
$$PWD/qdeclarativeobjectscriptclass.cpp \
@@ -112,6 +113,7 @@ HEADERS += \
$$PWD/qdeclarativepropertycache_p.h \
$$PWD/qdeclarativenotifier_p.h \
$$PWD/qdeclarativeintegercache_p.h \
+ $$PWD/qdeclarativetypenotavailable_p.h \
$$PWD/qdeclarativetypenamecache_p.h \
$$PWD/qdeclarativescriptstring.h \
$$PWD/qdeclarativeobjectscriptclass_p.h \
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index b9f1abb..ee72423 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -68,6 +68,8 @@
#include "private/qdeclarativetransitionmanager_p_p.h"
#include "private/qdeclarativetransition_p.h"
#include "qdeclarativeview.h"
+#include "qdeclarativeinfo.h"
+#include "private/qdeclarativetypenotavailable_p.h"
#ifndef QT_NO_XMLPATTERNS
#include "private/qdeclarativexmllistmodel_p.h"
#endif
@@ -103,7 +105,12 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeTimer>("Qt",4,6,"Timer");
qmlRegisterType<QDeclarativeTransition>("Qt",4,6,"Transition");
qmlRegisterType<QDeclarativeVector3dAnimation>("Qt",4,6,"Vector3dAnimation");
-#ifndef QT_NO_XMLPATTERNS
+#ifdef QT_NO_XMLPATTERNS
+ qmlRegisterTypeNotAvailable("Qt",4,6,"XmlListModel",
+ qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns"));
+ qmlRegisterTypeNotAvailable("Qt",4,6,"XmlRole",
+ qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns"));
+#else
qmlRegisterType<QDeclarativeXmlListModel>("Qt",4,6,"XmlListModel");
qmlRegisterType<QDeclarativeXmlListModelRole>("Qt",4,6,"XmlRole");
#endif
@@ -112,12 +119,11 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeStateOperation>();
qmlRegisterType<QDeclarativeAnchorSet>();
- qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("Qt",4,6,"Animation");
+ qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("Qt",4,6,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class"));
- qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel",
- new QDeclarativeListModelParser);
- qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges",
- new QDeclarativePropertyChangesParser);
- qmlRegisterCustomType<QDeclarativeConnections>("Qt", 4, 6, "Connections", "QDeclarativeConnections",
- new QDeclarativeConnectionsParser);
+ qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", new QDeclarativeListModelParser);
+ qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", new QDeclarativePropertyChangesParser);
+ qmlRegisterCustomType<QDeclarativeConnections>("Qt", 4, 6, "Connections", new QDeclarativeConnectionsParser);
}
+
+#include "qdeclarativeutilmodule.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt
new file mode 100644
index 0000000..23cd3f3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt
@@ -0,0 +1 @@
+3:1:Keys is only available via attached properties
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml
new file mode 100644
index 0000000..0612fa2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Keys {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index 623775a..5d87404 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -52,8 +52,7 @@ void registerTypes()
qmlRegisterType<MyNamespace::MySecondNamespacedType>("Test",1,0,"MySecondNamespacedType");
qmlRegisterType<MyGroupedObject>();
- qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", "MyCustomParserType",
- new MyCustomParserTypeParser);
+ qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
}
QVariant myCustomVariantTypeConverter(const QString &data)
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 07fbf83..3d56d1f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -330,6 +330,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
+ QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
}
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 7b4706b..68940c7 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -1431,7 +1431,7 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
- qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation");
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation","");
registered = true;
}
}