diff options
-rw-r--r-- | src/declarative/qml/v4/qv4irbuilder.cpp | 1 | ||||
-rw-r--r-- | tests/auto/declarative/v4/data/nestedLogicalOr.qml | 14 | ||||
-rw-r--r-- | tests/auto/declarative/v4/tst_v4.cpp | 16 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 2cc1c6eaab..604eeaa713 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -892,6 +892,7 @@ bool QV4IRBuilder::visit(AST::BinaryExpression *ast) _block = iftrue; ExprResult right = expression(ast->right); _block->MOVE(r, right); + _block->JUMP(endif); if (left.type() != right.type()) discard(); diff --git a/tests/auto/declarative/v4/data/nestedLogicalOr.qml b/tests/auto/declarative/v4/data/nestedLogicalOr.qml new file mode 100644 index 0000000000..c4478a3e7b --- /dev/null +++ b/tests/auto/declarative/v4/data/nestedLogicalOr.qml @@ -0,0 +1,14 @@ +import Qt.v4 1.0 + +Result { + property bool val1: false + property bool val2: true + property bool val3: false + + property bool b1: (false || false || true) + property bool b2: (false || (false || true)) + property bool b3: ((false || false) || true) + property bool b4: (val1 || (val2 || val3)) ? true : false + + result: b1 && b2 && b3 && b4 +} diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 751fb337b4..fb6f8776e0 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -62,6 +62,7 @@ private slots: void unnecessaryReeval(); void logicalOr(); + void nestedLogicalOr(); void conditionalExpr(); void qtscript(); void qtscript_data(); @@ -183,6 +184,21 @@ void tst_v4::logicalOr() } } +void tst_v4::nestedLogicalOr() +{ + //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) + QDeclarativeComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast<ResultObject *>(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; +} + void tst_v4::conditionalExpr() { { |