summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qqmlcodegenerator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-25 14:22:36 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-02 14:48:37 +0100
commit278ca02350c68a78c89bb34d99ee65968372a5fd (patch)
treec94b51848dc58f21a7b5e3d5f0d6068b11edbcdf /src/qml/compiler/qqmlcodegenerator.cpp
parent785ff10979f0c9ea21b9c3d5cc3eabf3c8c65115 (diff)
downloadqtdeclarative-278ca02350c68a78c89bb34d99ee65968372a5fd.tar.gz
[new compiler] Fix memory leaks
In memory pool allocated classes we cannot have members that require a destructor to run to free memory. Therefore this patch removes the QSets in the object class used for duplicate property and signal name checking. The checking is instead done using linear search, which should be fine given that usually the number declared signals and newly declared properties is low per type. Change-Id: Id7a7a9bdd9e145975dcee4d5340489615f4f71e3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator.cpp')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 40e678a6aa..35f303c9fc 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -102,8 +102,11 @@ QString QmlObject::sanityCheckFunctionNames(const QList<CompiledFunctionOrExpres
if (functionNames.contains(f->nameIndex))
return tr("Duplicate method name");
functionNames.insert(f->nameIndex);
- if (signalNames.contains(f->nameIndex))
- return tr("Duplicate method name");
+
+ for (QtQml::Signal *s = qmlSignals->first; s; s = s->next) {
+ if (s->nameIndex == f->nameIndex)
+ return tr("Duplicate method name");
+ }
if (name.at(0).isUpper())
return tr("Method names cannot begin with an upper case letter");
@@ -118,9 +121,12 @@ QString QmlObject::appendSignal(Signal *signal)
QmlObject *target = declarationsOverride;
if (!target)
target = this;
- if (target->signalNames.contains(signal->nameIndex))
- return tr("Duplicate signal name");
- target->signalNames.insert(signal->nameIndex);
+
+ for (Signal *s = qmlSignals->first; s; s = s->next) {
+ if (s->nameIndex == signal->nameIndex)
+ return tr("Duplicate signal name");
+ }
+
target->qmlSignals->append(signal);
return QString(); // no error
}
@@ -131,14 +137,13 @@ QString QmlObject::appendProperty(QmlProperty *prop, const QString &propertyName
if (!target)
target = this;
- if (target->propertyNames.contains(prop->nameIndex))
- return tr("Duplicate property name");
+ for (QmlProperty *p = target->properties->first; p; p = p->next)
+ if (p->nameIndex == prop->nameIndex)
+ return tr("Duplicate property name");
if (propertyName.constData()->isUpper())
return tr("Property names cannot begin with an upper case letter");
- target->propertyNames.insert(prop->nameIndex);
-
const int index = target->properties->append(prop);
if (isDefaultProperty) {
if (target->indexOfDefaultProperty != -1) {