[new compiler] Fix qquickvisualdatamodel tests
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 28 Feb 2014 07:12:55 +0000 (08:12 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 2 Mar 2014 19:52:24 +0000 (20:52 +0100)
Allow for signal handlers to be installed on group property objects. We determine
the property cache objects earlier correctly, so the empyt type name check is not
necessary.

Change-Id: Idc38fdc1a78c0f4d5147ec882e7872a62510e790
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qqmlcodegenerator.cpp
src/qml/compiler/qqmlcodegenerator_p.h
src/qml/compiler/qqmltypecompiler.cpp

index 4a6d5bb..a3bfb20 100644 (file)
@@ -1770,11 +1770,12 @@ IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col)
 }
 
 SignalHandlerConverter::SignalHandlerConverter(QQmlEnginePrivate *enginePrivate, ParsedQML *parsedQML,
-                                               QQmlCompiledData *unit)
+                                               QQmlCompiledData *unit, const QVector<QQmlPropertyCache*> &propertyCaches)
     : enginePrivate(enginePrivate)
     , parsedQML(parsedQML)
     , unit(unit)
     , illegalNames(QV8Engine::get(QQmlEnginePrivate::get(enginePrivate))->illegalNames())
+    , propertyCaches(propertyCaches)
 {
 }
 
@@ -1782,16 +1783,16 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
 {
     for (int objectIndex = 0; objectIndex < parsedQML->objects.count(); ++objectIndex) {
         QmlObject * const obj = parsedQML->objects.at(objectIndex);
-        QString elementName = stringAt(obj->inheritedTypeNameIndex);
-        if (elementName.isEmpty())
-            continue;
-        QQmlCompiledData::TypeReference *tr = unit->resolvedTypes.value(obj->inheritedTypeNameIndex);
-        QQmlCustomParser *customParser = (tr && tr->type) ? tr->type->customParser() : 0;
-        if (customParser && !(customParser->flags() & QQmlCustomParser::AcceptsSignalHandlers))
-            continue;
-        QQmlPropertyCache *cache = unit->propertyCaches.value(objectIndex);
+        QQmlPropertyCache *cache = propertyCaches.at(objectIndex);
         if (!cache)
             continue;
+        QString elementName = stringAt(obj->inheritedTypeNameIndex);
+        if (!elementName.isEmpty()) {
+            QQmlCompiledData::TypeReference *tr = unit->resolvedTypes.value(obj->inheritedTypeNameIndex);
+            QQmlCustomParser *customParser = (tr && tr->type) ? tr->type->customParser() : 0;
+            if (customParser && !(customParser->flags() & QQmlCustomParser::AcceptsSignalHandlers))
+                continue;
+        }
         if (!convertSignalHandlerExpressionsToFunctionDeclarations(obj, elementName, cache))
             return false;
     }
index 304df22..22cf915 100644 (file)
@@ -458,7 +458,7 @@ struct SignalHandlerConverter
     Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator)
 public:
     SignalHandlerConverter(QQmlEnginePrivate *enginePrivate, ParsedQML *parsedQML,
-                           QQmlCompiledData *unit);
+                           QQmlCompiledData *unit, const QVector<QQmlPropertyCache *> &propertyCaches);
 
     bool convertSignalHandlerExpressionsToFunctionDeclarations();
 
@@ -474,6 +474,7 @@ private:
     ParsedQML *parsedQML;
     QQmlCompiledData *unit;
     const QSet<QString> &illegalNames;
+    const QVector<QQmlPropertyCache*> &propertyCaches;
 };
 
 struct Q_QML_EXPORT JSCodeGen : public QQmlJS::Codegen
index 24234e8..b04c65c 100644 (file)
@@ -144,7 +144,7 @@ bool QQmlTypeCompiler::compile()
     }
 
     {
-        SignalHandlerConverter converter(engine, parsedQML, compiledData);
+        SignalHandlerConverter converter(engine, parsedQML, compiledData, propertyCaches());
         if (!converter.convertSignalHandlerExpressionsToFunctionDeclarations()) {
             errors << converter.errors;
             return false;