QmlCompiler: Avoid some deprecation warnings
QString::count() is deprecated, and also the "engine" argument to QQmlListReference. Also, properly convert the results of "length" retrieval. Change-Id: Ib7edde1326a0347902174a23147086b9deccfe17 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
6eff3465b5
commit
922b95ea15
|
@ -870,7 +870,6 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index)
|
|||
|
||||
Q_ASSERT(m_state.accumulatorOut().isProperty());
|
||||
|
||||
const QQmlJSScope::ConstPtr out = m_state.accumulatorOut().storedType();
|
||||
if (isReferenceType) {
|
||||
const QString lookup = u"aotContext->getObjectLookup("_qs + indexString
|
||||
+ u", "_qs + m_state.accumulatorVariableIn + u", "_qs
|
||||
|
@ -882,16 +881,23 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index)
|
|||
const QString preparation = getLookupPreparation(
|
||||
m_state.accumulatorOut(), m_state.accumulatorVariableOut, index);
|
||||
generateLookup(lookup, initialization, preparation);
|
||||
} else if (m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->listPropertyType())
|
||||
&& m_jsUnitGenerator->lookupName(index) == u"length"_qs) {
|
||||
m_body += m_state.accumulatorVariableOut + u" = "_qs;
|
||||
m_body += conversion(
|
||||
m_typeResolver->globalType(m_typeResolver->intType()), m_state.accumulatorOut(),
|
||||
m_state.accumulatorVariableIn + u".count("_qs + u'&'
|
||||
+ m_state.accumulatorVariableIn + u')');
|
||||
m_body += u";\n"_qs;
|
||||
} else if ((m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->stringType())
|
||||
|| accumulatorIn.storedType()->accessSemantics()
|
||||
== QQmlJSScope::AccessSemantics::Sequence)
|
||||
&& m_jsUnitGenerator->lookupName(index) == u"length"_qs) {
|
||||
// Special-cased the same way as in QQmlJSTypeResolver::memberType()
|
||||
m_body += m_state.accumulatorVariableOut + u" = "_qs + m_state.accumulatorVariableIn
|
||||
+ u".count("_qs;
|
||||
if (m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->listPropertyType()))
|
||||
m_body += u'&' + m_state.accumulatorVariableIn;
|
||||
m_body += u')' + u";\n"_qs;
|
||||
m_body += m_state.accumulatorVariableOut + u" = "_qs
|
||||
+ conversion(m_typeResolver->globalType(m_typeResolver->intType()),
|
||||
m_state.accumulatorOut(),
|
||||
m_state.accumulatorVariableIn + u".length()"_qs)
|
||||
+ u";\n"_qs;
|
||||
} else if (m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->jsValueType())) {
|
||||
reject(u"lookup in QJSValue"_qs);
|
||||
} else {
|
||||
|
|
|
@ -756,7 +756,7 @@ void tst_QmlCppCodegen::componentReturnType()
|
|||
QScopedPointer<QObject> object(component.create());
|
||||
|
||||
QCOMPARE(object->property("count").toInt(), 10);
|
||||
QCOMPARE(QQmlListReference(object.data(), "children", &engine).count(), 11);
|
||||
QCOMPARE(QQmlListReference(object.data(), "children").count(), 11);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::onAssignment()
|
||||
|
|
Loading…
Reference in New Issue