Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.15.2, 6.1.3, 6.2.0 Beta4
-
None
-
Arch Linux, KDE Plasma 5.22.5, both Qt from Arch and web installer are affected
Description
When an Item { visible: false } contains an Item (or subclass) containing a TextField { focus: true }, and no other items are focusable, then pressing Tab sends Qt into an infinite loop in QQuickItemPrivate::nextPrevItemInTabFocusChain(...).
I initially discovered this by pressing Tab on the KDE Plasma lock screen with the password entry screen invisible. I always got the hang, but other people could not reproduce this on their computers. However, both me and others could reproduce this by cloning https://github.com/KDE/kscreenlocker.git and running `qml[scene] greeter/fallbacktheme/Greeter.qml`. For more information about why the hang occurs, I chose to instead run `QT_LOGGING_RULES="qt.quick.focus=true" qml[scene] greeter/fallbacktheme/Greeter.qml`.
Because I wanted a simpler reproducer for this bug, I created and attached a minimal test caseĀ TabBug.qml, which is a single file which only depends on QQC2 and not KDE's custom QQC2-based widgets. (You can replace TextField with Button and the bug will still occur.) Run `QT_LOGGING_RULES="qt.quick.focus=true" qml TabBug.qml` in a console, and press Tab in the new window to trigger the hang.
I've attached a sample log file log.txt, showing the 2-item cycle that nextPrevItemInTabFocusChain gets trapped in. After trying to focus the TextField "control", the loop works it way back out to "middle" and the invisible "outer" item, before oscillating forever between QQuickRootItem and "outer".
The source code for QQuickItemPrivate::nextPrevItemInTabFocusChain() is at https://invent.kde.org/qt/qt/qtdeclarative/-/blob/kde/5.15/src/quick/items/qquickitem.cpp#L2481.
This bug appears to be a variant of QTBUG-59181, which was fixed, but adding an extra layer between `visible: false` and the focusable widget still triggers the endless loop.
Attachments
Issue Links
- relates to
-
QTBUG-59181 Freeze when hitting tab key
- Closed
-
QTBUG-87190 Application freezes when there is no control to focus next
- Closed