aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-09-06 14:14:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-08 09:00:31 +0200
commit8ac5506f2a6a8f1f6f50d3175a28e3e695f65a81 (patch)
tree00582e04f79809a5e8b07f989c0df995af6b6805 /src/qml/qml
parent2ed0cd0602093d316bfbce6b1f3f8f8bfe026fca (diff)
Fix error reporting for wrong signal parameter declarations
Record the line/column in the signal and report it together with the url if there was an error in declaring the signals. Change-Id: Idbbee9be271b0ca55709ffc1791637595d7ebd89 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp30
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h10
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h4
4 files changed, 34 insertions, 12 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index ff961c7822..a70b9064d9 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -895,7 +895,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
enginePriv->referenceScarceResources();
QObject *rv = 0;
if (enginePriv->useNewCompiler) {
- state.creator = new QtQml::QmlObjectCreator(engine, context, cc);
+ state.creator = new QtQml::QmlObjectCreator(engine, url, context, cc);
rv = state.creator->create();
if (!rv)
state.errors = state.creator->errors;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 724f97ef12..4f84cea151 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -63,8 +63,9 @@ static void removeBindingOnProperty(QObject *o, int index)
if (binding) binding->destroy();
}
-QmlObjectCreator::QmlObjectCreator(QQmlEngine *engine, QQmlContextData *contextData, QQmlCompiledData *runtimeData)
+QmlObjectCreator::QmlObjectCreator(QQmlEngine *engine, const QUrl &url, QQmlContextData *contextData, QQmlCompiledData *runtimeData)
: engine(engine)
+ , url(url)
, unit(runtimeData->qmlUnit)
, jsUnit(runtimeData->compilationUnit)
, context(contextData)
@@ -263,8 +264,11 @@ bool QmlObjectCreator::needsCustomMetaObject(const QV4::CompiledData::Object *ob
return obj->nProperties > 0 || obj->nSignals > 0 || obj->nFunctions > 0;
}
-// ###
-#define COMPILE_EXCEPTION(token, desc) {}
+#define COMPILE_EXCEPTION(token, desc) \
+ { \
+ recordError((token)->location, desc); \
+ return false; \
+ }
static QAtomicInt classIndexCounter(0);
@@ -423,9 +427,10 @@ bool QmlObjectCreator::createVMEMetaObjectAndPropertyCache(const QV4::CompiledDa
} else {
// lazily resolved type
Q_ASSERT(param->type == QV4::CompiledData::Property::Custom);
+ const QString customTypeName = stringAt(param->customTypeNameIndex);
QQmlType *qmltype = 0;
- if (!imports.resolveType(stringAt(param->customTypeNameIndex), &qmltype, 0, 0, 0))
- COMPILE_EXCEPTION(s, tr("Invalid signal parameter type: %1").arg(s->parameterTypeNames.at(i).toString()));
+ if (!imports.resolveType(customTypeName, &qmltype, 0, 0, 0))
+ COMPILE_EXCEPTION(s, tr("Invalid signal parameter type: %1").arg(customTypeName));
if (qmltype->isComposite()) {
QQmlTypeData *tdata = QQmlEnginePrivate::get(engine)->typeLoader.getType(qmltype->sourceUrl());
@@ -520,8 +525,9 @@ bool QmlObjectCreator::createVMEMetaObjectAndPropertyCache(const QV4::CompiledDa
p->type == QV4::CompiledData::Property::Custom);
QQmlType *qmltype = 0;
- if (!imports.resolveType(stringAt(p->customTypeNameIndex), &qmltype, 0, 0, 0))
- COMPILE_EXCEPTION(p, tr("Invalid property type"));
+ if (!imports.resolveType(stringAt(p->customTypeNameIndex), &qmltype, 0, 0, 0)) {
+ // COMPILE_EXCEPTION(p, tr("Invalid property type"));
+ }
Q_ASSERT(qmltype);
if (qmltype->isComposite()) {
@@ -690,3 +696,13 @@ bool QmlObjectCreator::valueAsBoolean(const QV4::CompiledData::Value *value)
return false;
}
+void QmlObjectCreator::recordError(const QV4::CompiledData::Location &location, const QString &description)
+{
+ QQmlError error;
+ error.setUrl(url);
+ error.setLine(location.line);
+ error.setColumn(location.column);
+ error.setDescription(description);
+ errors << error;
+}
+
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 553be6f075..e62efc3439 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -51,9 +51,12 @@ class QQmlAbstractBinding;
namespace QtQml {
-struct Q_QML_EXPORT QmlObjectCreator
+class Q_QML_EXPORT QmlObjectCreator
{
- QmlObjectCreator(QQmlEngine *engine,
+ Q_DECLARE_TR_FUNCTIONS(QQmlCompiler)
+public:
+
+ QmlObjectCreator(QQmlEngine *engine, const QUrl &url,
// extra data/output stored in these two
QQmlContextData *contextData,
QQmlCompiledData *runtimeData);
@@ -80,7 +83,10 @@ private:
static double valueAsNumber(const QV4::CompiledData::Value *value);
static bool valueAsBoolean(const QV4::CompiledData::Value *value);
+ void recordError(const QV4::CompiledData::Location &location, const QString &description);
+
QQmlEngine *engine;
+ QUrl url;
const QV4::CompiledData::QmlUnit *unit;
const QV4::CompiledData::CompilationUnit *jsUnit;
QQmlContextData *context;
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 0fd9252754..fe509843ab 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -67,7 +67,7 @@
QT_BEGIN_NAMESPACE
namespace QtQml {
-struct QmlObjectCreator;
+class QmlObjectCreator;
}
class QV8Engine;
@@ -343,7 +343,7 @@ protected:
private:
friend class QQmlEnginePrivate;
friend class QQmlCompiler;
- friend struct QtQml::QmlObjectCreator;
+ friend class QtQml::QmlObjectCreator;
inline QQmlPropertyCache *copy(int reserve);