From cc3ef6cd7af09f7410e29f2fe7e403e25a2768bc Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 1 Oct 2019 12:52:56 +0200 Subject: Doc: Rename section called StackView - a section title in a tutorial shouldn't be the name of a QML type only Task-number: QTBUG-78799 Change-Id: I661b639eb96926be2b92899fdbe241890d4ed6f4 Reviewed-by: Paul Wicking --- .../chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc index 0da8f7c5..49e98068 100644 --- a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc +++ b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc @@ -309,7 +309,7 @@ in an application. Here's the revised \c main.qml: \printuntil } \printuntil } -\section2 StackView +\section2 Navigating with StackView As its name suggests, StackView provides stack-based navigation. The last item to be \e "pushed" onto the stack is the first one to be removed, and the -- cgit v1.2.3 From 788865b805bc91151ac8fe18bf7b92b1212ee07d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 1 Oct 2019 15:09:01 +0200 Subject: Imagine: fix crash when switching between 9-patch and regular image Consider the following changes in source: normal.png => press.9.png => normal.png => focus.png If the last two events happen quickly, pixmapChange() can be called twice with no call to updatePaintNode() inbetween. On the first call, resetNode will be true (because ninePatch is not null since it is still in the process of going from a 9-patch image to a regular image), and on the second call, resetNode would be false if we didn't have this check. This results in the oldNode never being deleted, and QQuickImage tries to static_cast a QQuickNinePatchImage to a QSGInternalImageNode. Only change resetNode when it's false; i.e. when no reset is pending. updatePaintNode() will take care of setting it to false if it's true. Change-Id: I614c172c3e24fda2506f081f8fcdb6acd1c65fb8 Fixes: QTBUG-78790 Reviewed-by: Richard Moe Gustavsen --- .../controls/imagine/qquickninepatchimage.cpp | 19 +++++++- tests/auto/qquickimaginestyle/data/tst_imagine.qml | 48 +++++++++++++++++++++ .../auto/qquickimaginestyle/qquickimaginestyle.pro | 4 +- .../test-assets/button-background-1.png | Bin 0 -> 211 bytes .../test-assets/button-background-2.png | Bin 0 -> 211 bytes 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qquickimaginestyle/test-assets/button-background-1.png create mode 100644 tests/auto/qquickimaginestyle/test-assets/button-background-2.png diff --git a/src/imports/controls/imagine/qquickninepatchimage.cpp b/src/imports/controls/imagine/qquickninepatchimage.cpp index c840c6f8..7d5e4f71 100644 --- a/src/imports/controls/imagine/qquickninepatchimage.cpp +++ b/src/imports/controls/imagine/qquickninepatchimage.cpp @@ -397,7 +397,24 @@ void QQuickNinePatchImage::pixmapChange() d->updatePatches(); } else { - d->resetNode = !d->ninePatch.isNull(); + /* + Only change resetNode when it's false; i.e. when no reset is pending. + updatePaintNode() will take care of setting it to false if it's true. + + Consider the following changes in source: + + normal.png => press.9.png => normal.png => focus.png + + If the last two events happen quickly, pixmapChange() can be called + twice with no call to updatePaintNode() inbetween. On the first call, + resetNode will be true (because ninePatch is not null since it is still + in the process of going from a 9-patch image to a regular image), + and on the second call, resetNode would be false if we didn't have this check. + This results in the oldNode never being deleted, and QQuickImage + tries to static_cast a QQuickNinePatchImage to a QSGInternalImageNode. + */ + if (!d->resetNode) + d->resetNode = !d->ninePatch.isNull(); d->ninePatch = QImage(); } QQuickImage::pixmapChange(); diff --git a/tests/auto/qquickimaginestyle/data/tst_imagine.qml b/tests/auto/qquickimaginestyle/data/tst_imagine.qml index 03bb9602..b9078d78 100644 --- a/tests/auto/qquickimaginestyle/data/tst_imagine.qml +++ b/tests/auto/qquickimaginestyle/data/tst_imagine.qml @@ -54,6 +54,7 @@ import QtTest 1.1 import QtQuick.Templates 2.12 as T import QtQuick.Controls 2.12 import QtQuick.Controls.Imagine 2.12 +import QtQuick.Controls.Imagine.impl 2.12 TestCase { id: testCase @@ -105,4 +106,51 @@ TestCase { verify(control) compare(control.font.pixelSize, 80) } + + Component { + id: ninePatchImageComponent + + NinePatchImage { + property alias mouseArea: mouseArea + + MouseArea { + id: mouseArea + anchors.fill: parent + // The name of the images isn't important; we just want to check that + // going from regular to 9-patch to regular to regular works without crashing. + onPressed: parent.source = "qrc:/control-assets/button-background.9.png" + onReleased: parent.source = "qrc:/test-assets/button-background-1.png" + onClicked: parent.source = "qrc:/test-assets/button-background-2.png" + } + } + } + + Component { + id: signalSpyComponent + + SignalSpy {} + } + + // QTBUG-78790 + function test_switchBetween9PatchAndRegular() { + var ninePatchImage = createTemporaryObject(ninePatchImageComponent, testCase, + { source: "qrc:/test-assets/button-background-1.png" }) + verify(ninePatchImage) + + var clickSpy = signalSpyComponent.createObject(ninePatchImage, + { target: ninePatchImage.mouseArea, signalName: "clicked" }) + verify(clickSpy.valid) + + var afterRenderingSpy = signalSpyComponent.createObject(ninePatchImage, + { target: testCase.Window.window, signalName: "afterRendering" }) + verify(afterRenderingSpy.valid) + + mousePress(ninePatchImage) + // Wait max 1 second - in reality it should take a handful of milliseconds. + afterRenderingSpy.wait(1000) + mouseRelease(ninePatchImage) + compare(clickSpy.count, 1) + // Shouldn't result in a crash. + afterRenderingSpy.wait(1000) + } } diff --git a/tests/auto/qquickimaginestyle/qquickimaginestyle.pro b/tests/auto/qquickimaginestyle/qquickimaginestyle.pro index c421f2dc..4b1a309a 100644 --- a/tests/auto/qquickimaginestyle/qquickimaginestyle.pro +++ b/tests/auto/qquickimaginestyle/qquickimaginestyle.pro @@ -7,7 +7,9 @@ SOURCES += \ RESOURCES += \ $$PWD/qtquickcontrols2.conf \ - $$PWD/control-assets/button-background.9.png + $$PWD/control-assets/button-background.9.png \ + $$PWD/test-assets/button-background-1.png \ + $$PWD/test-assets/button-background-2.png OTHER_FILES += \ $$PWD/data/*.qml diff --git a/tests/auto/qquickimaginestyle/test-assets/button-background-1.png b/tests/auto/qquickimaginestyle/test-assets/button-background-1.png new file mode 100644 index 00000000..244b707b Binary files /dev/null and b/tests/auto/qquickimaginestyle/test-assets/button-background-1.png differ diff --git a/tests/auto/qquickimaginestyle/test-assets/button-background-2.png b/tests/auto/qquickimaginestyle/test-assets/button-background-2.png new file mode 100644 index 00000000..54f5ecd8 Binary files /dev/null and b/tests/auto/qquickimaginestyle/test-assets/button-background-2.png differ -- cgit v1.2.3 From eed033246e6ab0518c92a0bcc92f245741218db5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 27 Sep 2019 10:54:32 +0200 Subject: Add translation auto test to auto.pro This amends c18c7bd7f9596e5ad3d13876a91203e1ceba2544. Change-Id: I29b48d9c8e5889bb67ea3cbc14821b5621868b6f Reviewed-by: Andy Shaw --- tests/auto/auto.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d528b848..8612e2c1 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -30,3 +30,6 @@ SUBDIRS += \ revisions \ sanity \ snippets + +# Requires lrelease, which isn't always available in CI. +qtHaveModule(tools): translation -- cgit v1.2.3 From 2da83b321f41ce3a9581447e0209c9b827c2c397 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 9 Oct 2019 14:06:58 +0200 Subject: Universal: disable wrapping for TabBar The wrapping behavior makes for a poor user experience. Use ListView as other styles do. [ChangeLog][Universal][TabBar] Disabled wrapping. The Universal style TabBar now behaves like TabBar from other styles. Change-Id: I0a37490cdc2b81ff864ec682256f469a1a930628 Fixes: QTBUG-50027 Reviewed-by: Andy Shaw --- src/imports/controls/universal/TabBar.qml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/imports/controls/universal/TabBar.qml b/src/imports/controls/universal/TabBar.qml index ab660c93..c7d27cbd 100644 --- a/src/imports/controls/universal/TabBar.qml +++ b/src/imports/controls/universal/TabBar.qml @@ -46,23 +46,20 @@ T.TabBar { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding) - contentItem: PathView { + contentItem: ListView { model: control.contentModel currentIndex: control.currentIndex - interactive: false - snapMode: PathView.SnapToItem - movementDirection: PathView.Positive - highlightMoveDuration: 100 + spacing: control.spacing + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + flickableDirection: Flickable.AutoFlickIfNeeded + snapMode: ListView.SnapToItem - path: Path { - startX: control.count ? control.availableWidth / control.count / 2 : 0 - startY: control.availableHeight / 2 - PathLine { - x: control.count ? control.availableWidth + (control.availableWidth / control.count / 2) : 0 - y: control.availableHeight / 2 - } - } + highlightMoveDuration: 100 + highlightRangeMode: ListView.ApplyRange + preferredHighlightBegin: 48 + preferredHighlightEnd: width - 48 } background: Rectangle { -- cgit v1.2.3 From 9685d8f97e8bb448c90dd87b4e86c0ea8438436a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 11 Oct 2019 15:01:26 +0200 Subject: tst_qquickpopup: ignore ShaderEffectSource warning in debug builds It was commented out but should have been #ifdef'd, and the explanation is wrong. This amends 83fbf44. Change-Id: Ibe752d63a42805361b13edc6beafcf1f3738f02f Reviewed-by: Andy Shaw --- tests/auto/qquickpopup/tst_qquickpopup.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 4d238663..8a8cd143 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -1197,9 +1197,11 @@ void tst_QQuickPopup::toolTipCrashOnClose() QQuickWindow *window = helper.window; window->show(); - // TODO: Using ignoreMessage() fails in CI with macOS for release builds, - // so for now we let the warning through. -// QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); + // The warning only occurs with debug builds for some reason. + // In any case, the warning is irrelevant, but using ShaderEffectSource is important, so we ignore it. +#ifdef QT_DEBUG + QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); +#endif QVERIFY(QTest::qWaitForWindowActive(window)); QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); @@ -1215,9 +1217,9 @@ void tst_QQuickPopup::setOverlayParentToNull() QQuickWindow *window = helper.window; window->show(); - // TODO: Using ignoreMessage() fails in CI with macOS for release builds, - // so for now we let the warning through. -// QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); +#ifdef QT_DEBUG + QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); +#endif QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(QMetaObject::invokeMethod(window, "nullifyOverlayParent")); -- cgit v1.2.3