summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-01-11 06:24:27 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-01-11 06:24:27 (GMT)
commit95a6d0af38708004f592927d071e9c860015393b (patch)
tree976ce7be5f94478149e6bb41b36fa9975cb41871
parent8fa3f3f7f038f10dcd2bbd160f04275fe0efaadf (diff)
downloadQt-95a6d0af38708004f592927d071e9c860015393b.zip
Qt-95a6d0af38708004f592927d071e9c860015393b.tar.gz
Qt-95a6d0af38708004f592927d071e9c860015393b.tar.bz2
Don't double function'ize dynamic QML functions
-rw-r--r--src/declarative/qml/qmlcompiler.cpp11
-rw-r--r--tests/auto/declarative/qmlecmascript/data/methods.5.qml9
2 files changed, 16 insertions, 4 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 3b2009a..7d93c46 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -2355,6 +2355,8 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
((QmlVMEMetaData *)dynamicData.data())->signalCount++;
}
+ QStringList funcScripts;
+
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
Object::DynamicSlot &s = obj->dynamicSlots[ii];
QByteArray sig(s.name + '(');
@@ -2372,7 +2374,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
funcScript.append(QLatin1Char(')'));
funcScript.append(s.body);
funcScript.append(QLatin1Char(')'));
- s.body = funcScript;
+ funcScripts << funcScript;
QMetaMethodBuilder b = builder.addSlot(sig);
b.setReturnType("QVariant");
@@ -2380,20 +2382,21 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
((QmlVMEMetaData *)dynamicData.data())->methodCount++;
QmlVMEMetaData::MethodData methodData =
- { s.parameterNames.count(), 0, s.body.length(), 0 };
+ { s.parameterNames.count(), 0, funcScript.length(), 0 };
dynamicData.append((char *)&methodData, sizeof(methodData));
}
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
const Object::DynamicSlot &s = obj->dynamicSlots.at(ii);
+ const QString &funcScript = funcScripts.at(ii);
QmlVMEMetaData::MethodData *data =
((QmlVMEMetaData *)dynamicData.data())->methodData() + ii;
data->bodyOffset = dynamicData.size();
- dynamicData.append((const char *)s.body.constData(),
- (s.body.length() * sizeof(QChar)));
+ dynamicData.append((const char *)funcScript.constData(),
+ (funcScript.length() * sizeof(QChar)));
}
obj->metadata = builder.toRelocatableData();
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.5.qml b/tests/auto/declarative/qmlecmascript/data/methods.5.qml
new file mode 100644
index 0000000..3d45b15
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/methods.5.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ property alias x: item.x
+ Item { id: item }
+
+ function testFunction() { return 9; }
+ property int test: testFunction();
+}