aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlcodegenerator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-17 15:56:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-20 15:10:03 +0100
commit9d8e0365eb05f7a13a23fdd10e1c30a3c19a2064 (patch)
tree017ffc9c7c24b91919d59453b691b2505d19eaf0 /src/qml/compiler/qqmlcodegenerator.cpp
parentae0a2ea25714af603babe5aa0de364d1ebae1170 (diff)
[new compiler] Fix duplicate property/signal name detection for group objects
For a rectangle like this: color: "blue" border.color: "red" we must not issue a duplicate property error for "color" because they are in different objects. This patch fixes that by moving the sets for checking the presence of these into the object itself, so that the qSwap on _object also transitions to the correct property/signal name set. Change-Id: I9ac0e5877eb9f60b618b031f99290707de28112d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator.cpp')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 629671399d..54ee0c98bd 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -303,7 +303,7 @@ bool QQmlCodeGenerator::sanityCheckFunctionNames()
if (functionNames.contains(name))
COMPILE_EXCEPTION(function->identifierToken, tr("Duplicate method name"));
functionNames.insert(name);
- if (_signalNames.contains(name))
+ if (_object->signalNames.contains(name))
COMPILE_EXCEPTION(function->identifierToken, tr("Duplicate method name"));
if (name.at(0).isUpper())
@@ -327,16 +327,12 @@ int QQmlCodeGenerator::defineQMLObject(AST::UiQualifiedId *qualifiedTypeNameId,
_object->init(pool, registerString(asString(qualifiedTypeNameId)), emptyStringIndex, loc);
QSet<QString> propertyNames;
- qSwap(_propertyNames, propertyNames);
QSet<QString> signalNames;
- qSwap(_signalNames, signalNames);
accept(initializer);
sanityCheckFunctionNames();
- qSwap(_propertyNames, propertyNames);
- qSwap(_signalNames, signalNames);
qSwap(_object, obj);
return objectIndex;
}
@@ -586,9 +582,9 @@ bool QQmlCodeGenerator::visit(AST::UiPublicMember *node)
p = p->next;
}
- if (_signalNames.contains(signalName))
+ if (_object->signalNames.contains(signalName))
COMPILE_EXCEPTION(node->identifierToken, tr("Duplicate signal name"));
- _signalNames.insert(signalName);
+ _object->signalNames.insert(signalName);
if (signalName.at(0).isUpper())
COMPILE_EXCEPTION(node->identifierToken, tr("Signal names cannot begin with an upper case letter"));
@@ -992,10 +988,10 @@ bool QQmlCodeGenerator::sanityCheckPropertyName(const AST::SourceLocation &nameL
// List items are implement by multiple bindings to the same name, so allow duplicates.
if (!isListItemOnOrAssignment) {
- if (_propertyNames.contains(name))
+ if (_object->propertyNames.contains(name))
COMPILE_EXCEPTION(nameLocation, tr("Duplicate property name"));
- _propertyNames.insert(name);
+ _object->propertyNames.insert(name);
}
if (name.at(0).isUpper())