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

a11y: Freeze when querying QLineEdit word at offset matching text length

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 6.11
    • None
    • Debian testing, qtbase self-compiled from git dev as of d61356bf323a67c7b723ddba3fe2ad719c5b91b3
    • Linux/Wayland, Linux/X11

      When calling QAccessibleTextInterface::textAtOffset on a QLineEdit's accessible object using the text length for the offset parameter, this triggers an infinite recursion and the app freezes and has to be killed manually.

      Issue was originally mentioned here (but is independent of that particular change): https://codereview.qt-project.org/c/qt/qtbase/+/679128/comments/858485c5_cd1a76ea

      Sample steps to reproduce, using the corresponding methods of the AT-SPI2 Text interface on Linux:

      1. Build and run this sample program
        #include <QApplication>
        #include <QLineEdit>
        #include <QMainWindow>
        #include <QTextEdit>
        #include <QVBoxLayout>
        
        int main(int argc, char* argv[])
        {
            QApplication a(argc, argv);
            QMainWindow w;
        
            QWidget* widget = new QWidget;
            w.setCentralWidget(widget);
        
            QVBoxLayout* layout = new QVBoxLayout(widget);
        
            layout->addWidget(new QLineEdit("Hello world"));
            layout->addWidget(new QTextEdit("Hello world"));
        
            w.show();
            return a.exec();
        }
      2. start Accerciser Accessibility Explorer ( https://gitlab.gnome.org/GNOME/accerciser )
      3. in Accerciser's treeview of the sample program's a11y hierarchy, select the object for the QLineEdit
      4. in Accerciser's IPython console, try to get word at the end, using the AT-SPI2 Text interface
        In [117]: text = acc.queryText()
        In [118]: text.characterCount
        Out[118]: 11
        In [119]: text.getTextAtOffset(11, 1)
        ---------------------------------------------------------------------------
        Error                                     Traceback (most recent call last)
        Cell In[119], line 1
        ----> 1 text.getTextAtOffset(11, 1)
        
        File /usr/lib/python3/dist-packages/pyatspi/text.py:469, in Text.getTextAtOffset(self, offset, type)
            444 def getTextAtOffset(self, offset, type):
            445         """
            446         Deprecated in favor of getStringAtOffset.
            447         Obtain a subset of the text content of an object which includes
           (...)
            467         the object, delimited by the specified boundary condition.
            468         """
        --> 469         ret = Atspi.Text.get_text_at_offset(self.obj, offset, type)
            470         return textRangeToList(ret)
        
        Error: atspi_error: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. (1)
        

      Actual result:
      The sample app freezes.
      Accerciser prints an error because it didn't receive any result from the app.

      Expected result:
      The app should return a result and remain responsive.

        For Gerrit Dashboard: QTBUG-141388
        # Subject Branch Project Status CR V

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            michaelweghorn Michael Weghorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change