From 64714ea431f2fd355ed27edc69dba4e992511e75 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 4 Nov 2016 00:11:59 +0100 Subject: QV4String: properly detect overflow when trying to convert to an array index A wrong overflow detection caused strings like "240000000000" to pass the conversion, even though they would not fit into a uint when converted into base-10. This mis-conversion to uint then caused all sorts of side effects (broken comparisons, wrong listing of properties, and so on). So, properly fix the overflow detection by using our numeric private functions. Change-Id: Icbf67ac68cf5785d6c77b433c7a45aed5285a8c2 Task-number: QTBUG-56830 Reviewed-by: Lars Knoll --- tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 27 +++++++++++++++++++++++++++ tests/auto/qml/qjsvalue/tst_qjsvalue.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index bf9bd18807..b9a9fec6d9 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1371,6 +1371,33 @@ void tst_QJSValue::hasProperty_changePrototype() QVERIFY(obj.hasOwnProperty("foo")); } +void tst_QJSValue::hasProperty_QTBUG56830_data() +{ + QTest::addColumn("key"); + QTest::addColumn("lookup"); + + QTest::newRow("bugreport-1") << QStringLiteral("240000000000") << QStringLiteral("3776798720"); + QTest::newRow("bugreport-2") << QStringLiteral("240000000001") << QStringLiteral("3776798721"); + QTest::newRow("biggest-ok-before-bug") << QStringLiteral("238609294221") << QStringLiteral("2386092941"); + QTest::newRow("smallest-bugged") << QStringLiteral("238609294222") << QStringLiteral("2386092942"); + QTest::newRow("biggest-bugged") << QStringLiteral("249108103166") << QStringLiteral("12884901886"); + QTest::newRow("smallest-ok-after-bug") << QStringLiteral("249108103167") << QStringLiteral("12884901887"); +} + +void tst_QJSValue::hasProperty_QTBUG56830() +{ + QFETCH(QString, key); + QFETCH(QString, lookup); + + QJSEngine eng; + const QJSValue value(42); + + QJSValue obj = eng.newObject(); + obj.setProperty(key, value); + QVERIFY(obj.hasProperty(key)); + QVERIFY(!obj.hasProperty(lookup)); +} + void tst_QJSValue::deleteProperty_basic() { QJSEngine eng; diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h index 16667ff344..485577bf97 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h @@ -97,6 +97,8 @@ private slots: void hasProperty_basic(); void hasProperty_globalObject(); void hasProperty_changePrototype(); + void hasProperty_QTBUG56830_data(); + void hasProperty_QTBUG56830(); void deleteProperty_basic(); void deleteProperty_globalObject(); -- cgit v1.2.3 From f4ac007f4a19bc095ff15d415a6629986de78e49 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 9 Nov 2016 16:06:56 +0100 Subject: Fix more cases where DSE would optimize out too many stores GCC5/6 do aggressive dead store elimination on memory passed to placement-new. This resulted in the Heap::Object::prototype being a nullptr. qml.pro already contained the -fno-lifetime-dse flag, but there are other places where we ask the memory manager to allocate data. This is temporary band-aid, and is already fixed in 5.8. Change-Id: Ia61a69f65fab351068a588cfc36b5b3d762ffc9f Task-number: QTBUG-56932 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/qqmlecmascript.pro | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro index 6f3f765aba..21e745f58e 100644 --- a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -13,6 +13,11 @@ RESOURCES += qqmlecmascript.qrc include (../../shared/util.pri) +greaterThan(QT_GCC_MAJOR_VERSION, 5) { + # Our code is bad. Temporary workaround. Fixed in 5.8 + QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse +} + # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -- cgit v1.2.3 From 769002ffe4a93995447a71393371579b1df41e12 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 14 Sep 2016 10:48:36 +0200 Subject: TextEdit: set cursor delegate's height to match the selected font RichText can have blocks of text with varying font sizes, so we must ensure that the cursor delegate's height is also set when it's moved to a different position in the text. Change-Id: I00691a94a2360c7d3272571fc4ba0da28b01006a Task-number: QTBUG-54934 Reviewed-by: J-P Nurmi --- .../quick/qquicktextedit/data/cursorHeight.qml | 20 ++++++++++++ .../quick/qquicktextedit/tst_qquicktextedit.cpp | 38 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/auto/quick/qquicktextedit/data/cursorHeight.qml (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktextedit/data/cursorHeight.qml b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml new file mode 100644 index 0000000000..b831a9eb6f --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 300 + color: "white" + + TextEdit { + objectName: "textEditObject" + width: 300 + height: 300 + text: "Blah
blah" + textFormat: TextEdit.RichText + cursorDelegate: Rectangle { + objectName: "cursorInstance" + color: "red" + width: 2 + } + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index cb2a7bfd83..fa5a0a254d 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -139,6 +139,7 @@ private slots: void cursorVisible(); void delegateLoading_data(); void delegateLoading(); + void cursorDelegateHeight(); void navigation(); void readOnly(); #ifndef QT_NO_CLIPBOARD @@ -2779,6 +2780,43 @@ void tst_qquicktextedit::delegateLoading() //QVERIFY(!delegate); } +void tst_qquicktextedit::cursorDelegateHeight() +{ + QQuickView view(testFileUrl("cursorHeight.qml")); + view.show(); + view.requestActivate(); + QTest::qWaitForWindowActive(&view); + QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); + QVERIFY(textEditObject); + // Delegate creation is deferred until focus in or cursor visibility is forced. + QVERIFY(!textEditObject->findChild("cursorInstance")); + QVERIFY(!textEditObject->isCursorVisible()); + + // Test that the delegate gets created. + textEditObject->setFocus(true); + QVERIFY(textEditObject->isCursorVisible()); + QQuickItem* delegateObject = textEditObject->findChild("cursorInstance"); + QVERIFY(delegateObject); + + const int largerHeight = textEditObject->cursorRectangle().height(); + + textEditObject->setCursorPosition(0); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Move the cursor to the next line, which has a smaller font. + textEditObject->setCursorPosition(5); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QVERIFY(textEditObject->cursorRectangle().height() < largerHeight); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Test that the delegate gets deleted + textEditObject->setCursorDelegate(0); + QVERIFY(!textEditObject->findChild("cursorInstance")); +} + /* TextEdit element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. -- cgit v1.2.3 From 8ff69297eeddc3f5650c4cc5517c7e2eafaf6c59 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Oct 2016 07:52:24 -0500 Subject: Setting Connection's target to null should disconnect implicit target Change-Id: Id7c8c7080e6db8bb6d09c1df13cddaef047cf611 Task-number: QTBUG-56499 Reviewed-by: J-P Nurmi --- .../data/test-connection-implicit.qml | 9 ++++++++ .../qml/qqmlconnections/tst_qqmlconnections.cpp | 27 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml new file mode 100644 index 0000000000..d5aa0f102a --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + width: 50 + + property bool tested: false + + Connections { onWidthChanged: tested = true } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index e529c74acc..eaf08a2a26 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -56,6 +56,7 @@ private slots: void errors(); void rewriteErrors(); void singletonTypeTarget(); + void clearImplicitTarget(); private: QQmlEngine engine; @@ -329,6 +330,32 @@ void tst_qqmlconnections::singletonTypeTarget() delete object; } +//QTBUG-56499 +void tst_qqmlconnections::clearImplicitTarget() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml")); + QQuickItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + // normal case: fire Connections + item->setWidth(100.); + QCOMPARE(item->property("tested").toBool(), true); + + item->setProperty("tested", false); + // clear the implicit target + QQmlConnections *connections = item->findChild(); + QVERIFY(connections); + connections->setTarget(0); + + // target cleared: no longer fire Connections + item->setWidth(150.); + QCOMPARE(item->property("tested").toBool(), false); + + delete item; +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" -- cgit v1.2.3