Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96762

When focusable TextField is nested within invisible Item, pressing Tab hangs in nextPrevItemInTabFocusChain()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.15.2, 6.1.3, 6.2.0 Beta4
    • Quick: Controls 2
    • None
    • Arch Linux, KDE Plasma 5.22.5, both Qt from Arch and web installer are affected
    • Linux/X11

    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

        1. log.txt
          3 kB
        2. TabBug.qml
          0.5 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              nyanpasu64 Nyan Pasu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes