diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-05-05 12:09:47 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-05-10 02:20:18 +0200 |
commit | e51ff5c4935330b00d8039e435ec6cac60cfb875 (patch) | |
tree | 71ff29e47c693724d03e96048ce44d667d1e084e /src/widgets | |
parent | 8f6ec8cea2370247e8c65c192def5fc1a4e98c80 (diff) |
a11y: Don't add scrollbar container as a11y child if scroll bar is re-parented
If someone has, for unknown reasons, re-parented the scroll bar of a
scroll area to outside the scroll area, we should not blindly add the
parent widget of the scroll bar as an a11y child of the scroll area.
We don't need to explicitly add the scroll bar itself as a child either,
as that will be handled by whoever is the new parent widget, as a normal
scroll bar would.
Fixes: QTBUG-93768
Pick-to: 6.5 6.2
Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/accessible/complexwidgets.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 624090a2af..1248007417 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -477,13 +477,19 @@ QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const // Horizontal scrollBar container. QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar(); if (horizontalScrollBar && horizontalScrollBar->isVisible()) { - children.append(horizontalScrollBar->parentWidget()); + QWidget *scrollBarParent = horizontalScrollBar->parentWidget(); + // Add container only if scroll bar is in the container + if (elementType(scrollBarParent) == HorizontalContainer) + children.append(scrollBarParent); } // Vertical scrollBar container. QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar(); if (verticalScrollBar && verticalScrollBar->isVisible()) { - children.append(verticalScrollBar->parentWidget()); + QWidget *scrollBarParent = verticalScrollBar->parentWidget(); + // Add container only if scroll bar is in the container + if (elementType(scrollBarParent) == VerticalContainer) + children.append(scrollBarParent); } // CornerWidget. |