diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:22:16 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:22:16 +0300 |
commit | 69c1a1e86b9774fbee6958021055c899151e1955 (patch) | |
tree | cf8619fa03e1442b06ee13983d3c3c5d9f307669 | |
parent | 453e302ea51a9f628ccb1382e812b09f259f890b (diff) | |
parent | c379659f5f51ae14331e5bdd365ef229c9a4c9c9 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Change-Id: Ia55f51bc5a14b1b9f55e1ae4123f52d779e24e94
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | src/imports/controls/imagine/qquickninepatchimage.cpp | 14 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 6 | ||||
-rw-r--r-- | src/quicktemplates2/qtquicktemplates2global.cpp | 2 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 31 |
5 files changed, 45 insertions, 10 deletions
diff --git a/.qmake.conf b/.qmake.conf index 25b262d6..61cc6b14 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -5,4 +5,4 @@ DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST QQC2_SOURCE_TREE = $$PWD -MODULE_VERSION = 5.15.3 +MODULE_VERSION = 5.15.4 diff --git a/src/imports/controls/imagine/qquickninepatchimage.cpp b/src/imports/controls/imagine/qquickninepatchimage.cpp index 7d5e4f71..71243988 100644 --- a/src/imports/controls/imagine/qquickninepatchimage.cpp +++ b/src/imports/controls/imagine/qquickninepatchimage.cpp @@ -386,7 +386,12 @@ void QQuickNinePatchImage::pixmapChange() { Q_D(QQuickNinePatchImage); if (QFileInfo(d->url.fileName()).completeSuffix().toLower() == QLatin1String("9.png")) { - d->resetNode = d->ninePatch.isNull(); + // Keep resetNode if it is already set, we do not want to miss an + // ImageNode->NinePatchNode change. Without this there's a chance one gets + // an incorrect cast on oldNode every once in a while with source changes. + if (!d->resetNode) + d->resetNode = d->ninePatch.isNull(); + d->ninePatch = d->pix.image(); if (d->ninePatch.depth() != 32) d->ninePatch = d->ninePatch.convertToFormat(QImage::Format_ARGB32); @@ -449,6 +454,13 @@ QSGNode *QQuickNinePatchImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNode qsgnode_set_description(patchNode, QString::fromLatin1("QQuickNinePatchImage: '%1'").arg(d->url.toString())); #endif + // The image may wrap non-owned data (due to pixmapChange). Ensure we never + // pass such an image to the scenegraph, because with a separate render + // thread the data may become invalid (in a subsequent pixmapChange on the + // gui thread) by the time the renderer gets to do something with the QImage + // passed in here. + image.detach(); + QSGTexture *texture = window()->createTextureFromImage(image); patchNode->initialize(texture, sz * d->devicePixelRatio, image.size(), d->xDivs, d->yDivs, d->devicePixelRatio); return patchNode; diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index ea8d3d1d..b715659f 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1740,7 +1740,11 @@ void QQuickComboBox::focusInEvent(QFocusEvent *event) { Q_D(QQuickComboBox); QQuickControl::focusInEvent(event); - if (d->contentItem && isEditable()) + // Setting focus on TextField should not be done when drop down indicator was clicked + // That is why, if focus is not set with key reason, it should not be passed to textEdit by default. + // Focus on Edit Text should be set only intentionally by user. + if ((event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason || + event->reason() == Qt::ShortcutFocusReason) && d->contentItem && isEditable()) d->contentItem->forceActiveFocus(event->reason()); } diff --git a/src/quicktemplates2/qtquicktemplates2global.cpp b/src/quicktemplates2/qtquicktemplates2global.cpp index 9b79d60c..5d7816b4 100644 --- a/src/quicktemplates2/qtquicktemplates2global.cpp +++ b/src/quicktemplates2/qtquicktemplates2global.cpp @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE #if QT_CONFIG(accessibility) -QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object) +static QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object) { if (classname == u"QQuickPage") { return new QAccessibleQuickPage(qobject_cast<QQuickPage *>(object)); diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index cd4c8466..eaf9b3c6 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -1547,7 +1547,7 @@ TestCase { control.editText = "" compare(control.acceptableInput, true) control.editText = "" - control.forceActiveFocus() + control.contentItem.forceActiveFocus() keyPress(Qt.Key_A) compare(control.editText, "") keyPress(Qt.Key_A) @@ -1584,7 +1584,7 @@ TestCase { compare(control.currentIndex, 0) compare(control.currentText, "first") - control.forceActiveFocus() + control.contentItem.forceActiveFocus() compare(control.activeFocus, true) control.selectAll() @@ -1607,7 +1607,7 @@ TestCase { var control = createTemporaryObject(comboBox, testCase, {editable: true, model: ["Banana", "Coco", "Coconut", "Apple", "Cocomuffin"]}) verify(control) - control.forceActiveFocus() + control.contentItem.forceActiveFocus() verify(control.activeFocus) var acceptCount = 0 @@ -1758,7 +1758,7 @@ TestCase { var control = createTemporaryObject(keysAttachedBox, testCase) verify(control) - control.forceActiveFocus() + control.contentItem.forceActiveFocus() verify(control.activeFocus) verify(!control.gotit) @@ -2013,7 +2013,7 @@ TestCase { // Give the first ComboBox focus and type in 0 to select "Item 10" (default is "Item 1"). waitForRendering(comboBox1) - comboBox1.forceActiveFocus() + comboBox1.contentItem.forceActiveFocus() verify(comboBox1.activeFocus) keyClick(Qt.Key_0) compare(comboBox1.editText, "Item 10") @@ -2031,7 +2031,7 @@ TestCase { // Give focus back to the first ComboBox, and try the same thing except // with non-existing text; the currentIndex should not change. - comboBox1.forceActiveFocus() + comboBox1.contentItem.forceActiveFocus() verify(comboBox1.activeFocus) keySequence(StandardKey.SelectAll) compare(comboBox1.contentItem.selectedText, "Item 10") @@ -2043,4 +2043,23 @@ TestCase { compare(comboBox1.currentIndex, 9) compare(currentIndexSpy.count, 1) } + + // QTBUG-61021: text line should not be focused by default + // It causes (e.g. on Android) showing virtual keyboard when it is not needed + function test_doNotFocusTextLineByDefault() { + var control = createTemporaryObject(comboBox, testCase) + // Focus not set after creating combobox + verify(!control.activeFocus) + verify(!control.contentItem.focus) + + // After setting focus on combobox, text line should not be focused + control.forceActiveFocus() + verify(control.activeFocus) + verify(!control.contentItem.focus) + + // Text line is focused after intentional setting focus on it + control.contentItem.forceActiveFocus() + verify(control.activeFocus) + verify(control.contentItem.focus) + } } |