QmlCompiler: Return early after reject()
Otherwise we can run into an infinite loop.
Fixes: QTBUG-120322
Change-Id: I81f9402beb48faf09b4fe148271d4347b84ddc5e
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
(cherry picked from commit 49ea766c8f
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1207d0a374
commit
1a2faa748d
|
@ -4054,12 +4054,14 @@ QString QQmlJSCodeGenerator::convertContained(const QQmlJSRegisterContent &from,
|
|||
if (!m_typeResolver->registerIsStoredIn(to, m_typeResolver->varType()) &&
|
||||
!m_typeResolver->registerIsStoredIn(to, m_typeResolver->jsPrimitiveType())) {
|
||||
reject(u"internal conversion into unsupported wrapper type."_s);
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool isExtension = false;
|
||||
if (m_typeResolver->canPopulate(containedTo, containedFrom, &isExtension)) {
|
||||
reject(u"populating "_s + containedTo->internalName()
|
||||
+ u" from "_s + containedFrom->internalName());
|
||||
return QString();
|
||||
} else if (const auto ctor = m_typeResolver->selectConstructor(
|
||||
containedTo, containedFrom, &isExtension); ctor.isValid()) {
|
||||
const auto argumentTypes = ctor.parameters();
|
||||
|
|
|
@ -215,6 +215,7 @@ set(qml_files
|
|||
registerPropagation.qml
|
||||
registerelimination.qml
|
||||
renameAdjust.qml
|
||||
returnAfterReject.qml
|
||||
revisions.qml
|
||||
scopeIdLookup.qml
|
||||
scopeVsObject.qml
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import QtQml
|
||||
|
||||
QtObject {
|
||||
id: remaining
|
||||
|
||||
property int bar: 0
|
||||
|
||||
Component.onCompleted: {
|
||||
let remainingTime = 123
|
||||
if (remainingTime < 0) {
|
||||
remainingTime += 24 * 60 * 60
|
||||
}
|
||||
remaining.bar = isNaN(remainingTime) ? 0 : remainingTime
|
||||
}
|
||||
}
|
|
@ -183,6 +183,7 @@ private slots:
|
|||
void registerElimination();
|
||||
void registerPropagation();
|
||||
void renameAdjust();
|
||||
void returnAfterReject();
|
||||
void revisions();
|
||||
void scopeIdLookup();
|
||||
void scopeObjectDestruction();
|
||||
|
@ -3802,6 +3803,16 @@ void tst_QmlCppCodegen::renameAdjust()
|
|||
QVERIFY(o);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::returnAfterReject()
|
||||
{
|
||||
QQmlEngine engine;
|
||||
QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/returnAfterReject.qml"_s));
|
||||
QVERIFY2(c.isReady(), qPrintable(c.errorString()));
|
||||
QScopedPointer<QObject> o(c.create());
|
||||
QVERIFY(o);
|
||||
QCOMPARE(o->property("bar").toInt(), 123);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::revisions()
|
||||
{
|
||||
QQmlEngine engine;
|
||||
|
|
Loading…
Reference in New Issue