Fix crashes with AT-SPI2 screen readers (Orca) on Linux#3191
Draft
danijel1124 wants to merge 2 commits into
Draft
Fix crashes with AT-SPI2 screen readers (Orca) on Linux#3191danijel1124 wants to merge 2 commits into
danijel1124 wants to merge 2 commits into
Conversation
QTableView with a screen reader active crashed in several ways due to bugs in Qt 6.4.x's QAccessibleTable implementation. This replaces the default accessibility backend for MyTableView with a custom one that: - Guards focusChild() against invalid (unselected) current index, preventing cellAt(-1,-1) calls that crash the AT-SPI2 bridge - Returns a dummy cell instead of nullptr from cellAt() and child(), working around a missing null-check in atspiadaptor.cpp - Uses QAccessible::Id (Qt-managed IDs) for the cell cache instead of raw pointers, preventing dangling-pointer crashes when the dialog is closed while a screen reader is active - Fixes child index mapping to account for header rows/columns, matching Qt's own accessibleTable2Index() formula - Implements all pure virtual methods of QAccessibleTableInterface Also adds ensureSelection() so the table always has a current index when shown, further reducing the chance of focus-related AT-SPI2 errors. Tested with Orca on Ubuntu 24.04 / Qt 6.4.2: server list opens, navigation works, reconnect works, dialog close works without crash. Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bear101
reviewed
Mar 26, 2026
| void MyTableView::showEvent(QShowEvent* e) | ||
| { | ||
| QTableView::showEvent(e); | ||
| ensureSelection(); |
|
|
||
| MyTableView::MyTableView(QWidget* parent/* = nullptr*/) : QTableView(parent) | ||
| { | ||
| QAccessible::installFactory(myTableViewFactory); |
Contributor
There was a problem hiding this comment.
This should probably have a:
#if defined(Q_OS_LINUX) && QT_VERSION == QT_VERSION_CHECK(6,4,0)
I'm not aware that other platforms have this issue or other Qt versions.
Contributor
|
I'm changing this to Draft because the changes have unknown side effects on macOS and Windows as well as other versions of Qt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QTableViewwith an active screen reader (Orca/AT-SPI2) crashed in several ways due to bugs in Qt 6.4.x'sQAccessibleTableimplementationMyTableViewwith a customMyTableViewAccessiblethat fixes all identified crash pathsWhat was fixed
focusChild()with no selection — guards against invalid current index, preventingcellAt(-1,-1)calls that crash the AT-SPI2 bridgechild()/cellAt()returning nullptr — returns a dummy cell instead, working around a missing null-check inatspiadaptor.cppQAccessible::Id(Qt-managed IDs) for the cell cache instead of raw pointersaccessibleTable2Index()formulaQAccessibleTableInterfaceimplementedensureSelection()— table always has a current index when shown, reducing AT-SPI2 focus errorsTest plan