summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-04 06:04:15 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-04 06:04:59 (GMT)
commit57d68b06c15f8426c25e357f97b9154056969e0f (patch)
treecdd224b86ea9bbead3f92563aadae34285885db6 /src/declarative
parent5599ddd113fe1385e7a6aff708e12af419b8de87 (diff)
downloadQt-57d68b06c15f8426c25e357f97b9154056969e0f.zip
Qt-57d68b06c15f8426c25e357f97b9154056969e0f.tar.gz
Qt-57d68b06c15f8426c25e357f97b9154056969e0f.tar.bz2
Improve grouped property error messages
QT-2579
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h7
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp4
4 files changed, 22 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 7a3dde9..32c746f 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -1789,13 +1789,19 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
- if (prop->values.count())
- COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler", "Invalid value in grouped property"));
-
if (QDeclarativeValueTypeFactory::isValueType(prop->type)) {
QDeclarativeEnginePrivate *ep =
static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine));
if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
+
+ if (prop->values.count()) {
+ if (prop->values.at(0)->location < prop->value->location) {
+ COMPILE_EXCEPTION(prop->value, QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ } else {
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ }
+ }
+
COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
prop->value, obj, ctxt.incr()));
obj->addValueTypeProperty(prop);
@@ -1810,6 +1816,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
if (!prop->value->metatype)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access"));
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Cannot assign a value directly to a grouped property"));
+
obj->addGroupedProperty(prop);
COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 0e3d856..b0599ad 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -226,9 +226,9 @@ QDeclarativeParser::Property::~Property()
if (value) value->release();
}
-Object *QDeclarativeParser::Property::getValue()
+Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
{
- if (!value) value = new Object;
+ if (!value) { value = new Object; value->location = l; }
return value;
}
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index d0d7de1..5bf4b68 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -104,6 +104,11 @@ namespace QDeclarativeParser
Location start;
Location end;
LocationRange range;
+
+ bool operator<(LocationSpan &o) const {
+ return (start.line < o.start.line) ||
+ (start.line == o.start.line && start.column < o.start.column);
+ }
};
class Property;
@@ -318,7 +323,7 @@ namespace QDeclarativeParser
// The Object to which this property is attached
Object *parent;
- Object *getValue();
+ Object *getValue(const LocationSpan &);
void addValue(Value *v);
void addOnValue(Value *v);
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index a4b3668..fe516c5 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -85,8 +85,8 @@ class ProcessAST: protected AST::Visitor
{
const State &state = top();
if (state.property) {
- State s(state.property->getValue(),
- state.property->getValue()->getProperty(name.toUtf8()));
+ State s(state.property->getValue(location),
+ state.property->getValue(location)->getProperty(name.toUtf8()));
s.property->location = location;
push(s);
} else {