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

AT-SPI: Wrong char reported by GetCharAtOffset when code point > 65535

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.3, 6.6.0 Beta1, 6.7.0 FF
    • dev
    • None
    • Debian testing ("bookworm"), Qtbase self-compiled from dev branch as of commit 59f8da17e6a2989b072254970d23281301114503
    • Linux/X11
    • c7b925757 (dev), 1cdc19766 (6.6), 23b05211c (6.5)

    Description

      When retrieving the character at the current cursor/caret position using the GetCharAtOffset method from the AT-SPI Text interface, the character is not correctly reported when its UTF-16 representation has 2 surrogate pairs, i.e. it has a Unicode code point above 65535.

      Sample steps to reproduce:

      1) build the attached sample program "qt-sample-app-character":

      cmake .
      make
      

      2) run the app, which has a QTextEdit with the text "abc𐐷d" and moves the cursor to before the "𐐷" (U+10437) character
      3) run the attached Python/pyatspi script that retrieves the character at the cursor position using the GetCharAtOffset method from the AT-SPI text interface tha the QTextEdit provides on Linux.

      Actual result:
      An incorrect code point is reported:

      $ python3 pyatspi-script-print-char-at-cursor.py 
      code point of char at cursor: 0xfffffff0
      Traceback (most recent call last):
        File "/home/michi/git/computer-doc/TODO/misc/pyatspi-script-print-char-at-cursor.py", line 42, in <module>
          print('char at cursor: {}'.format(chr(char_at_cursor)))
                                            ^^^^^^^^^^^^^^^^^^^
      OverflowError: Python int too large to convert to C int
      

      Expected result:
      The script should print the unicode codepoint of the "𐐷" character in hex ("0x10437") and the original character:

      $ python3 pyatspi-script-print-char-at-cursor.py 
      code point of char at cursor: 0x10437
      char at cursor: 𐐷
      

       
      Note: There's a similar/related Gerrit change for LibreOffice:
      https://gerrit.libreoffice.org/c/core/+/151303

      Attachments

        1. pyatspi-script-print-char-at-cursor.py
          0.9 kB
          Michael Weghorn
        2. qt-sample-app-character.zip
          2 kB
          Michael Weghorn
        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
            michaelweghorn Michael Weghorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes