summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-16 07:08:50 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-16 07:08:50 (GMT)
commitd71ef06fc1261968b8c5ecf7a438db02e2654b29 (patch)
treef530a2b311bea40e13fdfe2bb2da0ccb4aa72b65 /src/declarative
parentd080c1c2ded0d59974f86f9f3dac91b099bda0a9 (diff)
downloadQt-d71ef06fc1261968b8c5ecf7a438db02e2654b29.zip
Qt-d71ef06fc1261968b8c5ecf7a438db02e2654b29.tar.gz
Qt-d71ef06fc1261968b8c5ecf7a438db02e2654b29.tar.bz2
Protect against overriding FINAL properties
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp12
-rw-r--r--src/declarative/qml/qmldom.cpp4
-rw-r--r--src/declarative/qml/qmlparser.cpp2
-rw-r--r--src/declarative/qml/qmlparser_p.h2
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp4
5 files changed, 16 insertions, 8 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 182495a..b0bc6e8 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -160,8 +160,8 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
QString exceptionDescription; \
QmlError error; \
error.setUrl(output->url); \
- error.setLine(token->location.start.line); \
- error.setColumn(token->location.start.column); \
+ error.setLine((token)->location.start.line); \
+ error.setColumn((token)->location.start.column); \
QDebug d(&exceptionDescription); \
d << desc; \
error.setDescription(exceptionDescription.trimmed()); \
@@ -1738,6 +1738,14 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+ int propIdx =
+ obj->metaObject()->indexOfProperty(p.name.constData());
+ if (-1 != propIdx) {
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+ if (prop.isFinal())
+ COMPILE_EXCEPTION(&p, "Cannot override FINAL property");
+ }
+
if (p.isDefaultProperty &&
(p.type != Object::DynamicProperty::Alias ||
mode == ResolveAliases))
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 505d872..293ea6a 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -587,7 +587,7 @@ QmlDomProperty QmlDomDynamicProperty::defaultValue() const
int QmlDomDynamicProperty::position() const
{
if (isValid()) {
- return d->property.range.offset;
+ return d->property.location.range.offset;
} else
return -1;
}
@@ -599,7 +599,7 @@ int QmlDomDynamicProperty::position() const
int QmlDomDynamicProperty::length() const
{
if (isValid())
- return d->property.range.length;
+ return d->property.location.range.length;
else
return -1;
}
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index e2d334e..8eb58c8 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -146,7 +146,7 @@ QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o)
type(o.type),
name(o.name),
defaultValue(o.defaultValue),
- range(o.range)
+ location(o.location)
{
}
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index 84e6dd4..d23b4ea 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -169,7 +169,7 @@ namespace QmlParser
Type type;
QByteArray name;
QmlParser::Property *defaultValue;
- LocationRange range;
+ LocationSpan location;
};
struct DynamicSignal {
DynamicSignal();
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 5f97c71..c1c11c7 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -530,8 +530,8 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
property.isDefaultProperty = node->isDefaultMember;
property.type = type;
property.name = name.toUtf8();
- property.range.offset = node->firstSourceLocation().offset;
- property.range.length = node->semicolonToken.end() - property.range.offset;
+ property.location = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
if (node->expression) { // default value
property.defaultValue = new Property;