QmlCompiler: Place code for CmpNeInt in parentheses
Otherwise it will apply the '!' to the first argument. Fixes: QTBUG-100480 Pick-to: 6.2 6.3 Change-Id: Iaefa25d062ad8bbd9d4278ffeaa52fc53ed417e2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
8fe35a003b
commit
db6459665c
|
@ -1904,8 +1904,8 @@ void QQmlJSCodeGenerator::generate_CmpNeInt(int lhsConst)
|
|||
{
|
||||
INJECT_TRACE_INFO(generate_CmpNeInt);
|
||||
|
||||
m_body += m_state.accumulatorVariableOut + u" = !"_qs + eqIntExpression(lhsConst)
|
||||
+ u";\n"_qs;
|
||||
m_body += m_state.accumulatorVariableOut + u" = !("_qs + eqIntExpression(lhsConst)
|
||||
+ u");\n"_qs;
|
||||
}
|
||||
|
||||
void QQmlJSCodeGenerator::generate_CmpEq(int lhs)
|
||||
|
|
|
@ -86,6 +86,7 @@ set(qml_files
|
|||
noQQmlData.qml
|
||||
nonNotifyable.qml
|
||||
noscope.qml
|
||||
notEqualsInt.qml
|
||||
nullAccess.qml
|
||||
outOfBounds.qml
|
||||
overriddenMember.qml
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import QtQml
|
||||
|
||||
QtObject {
|
||||
property int someValue: 42
|
||||
function foo() {
|
||||
if (someValue != 0) {
|
||||
t.text = "Bar";
|
||||
}
|
||||
}
|
||||
|
||||
property QtObject tt: QtObject {
|
||||
id: t
|
||||
property string text: "Foo"
|
||||
}
|
||||
}
|
|
@ -116,6 +116,7 @@ private slots:
|
|||
void popContextAfterRet();
|
||||
void revisions();
|
||||
void invisibleBase();
|
||||
void notEqualsInt();
|
||||
};
|
||||
|
||||
void tst_QmlCppCodegen::simpleBinding()
|
||||
|
@ -1738,6 +1739,20 @@ void tst_QmlCppCodegen::invisibleBase()
|
|||
QCOMPARE(qvariant_cast<QObject *>(o->property("n")), o.data());
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::notEqualsInt()
|
||||
{
|
||||
QQmlEngine engine;
|
||||
QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/notEqualsInt.qml"_qs));
|
||||
QVERIFY2(c.isReady(), qPrintable(c.errorString()));
|
||||
QScopedPointer<QObject> o(c.create());
|
||||
QVERIFY(o);
|
||||
QObject *t = qmlContext(o.data())->objectForName(u"t"_qs);
|
||||
QVERIFY(t);
|
||||
QCOMPARE(t->property("text").toString(), u"Foo"_qs);
|
||||
QMetaObject::invokeMethod(o.data(), "foo");
|
||||
QCOMPARE(t->property("text").toString(), u"Bar"_qs);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::runInterpreted()
|
||||
{
|
||||
if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER"))
|
||||
|
|
Loading…
Reference in New Issue