Do not update accessibility for invalid interfaces
Change-Id: I8dc29ea51393406e529c76f25bf2f8cf426e26cf Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
parent
6ec9b34cbb
commit
6d9541ae96
@ -169,7 +169,9 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
|
|||||||
// An event has to be associated with a window,
|
// An event has to be associated with a window,
|
||||||
// so find the first parent that is a widget and that has a WId
|
// so find the first parent that is a widget and that has a WId
|
||||||
QAccessibleInterface *iface = event->accessibleInterface();
|
QAccessibleInterface *iface = event->accessibleInterface();
|
||||||
QWindow *window = iface ? QWindowsAccessibility::windowHelper(iface) : 0;
|
if (!iface) // ### This should not happen, maybe make it an assert.
|
||||||
|
return;
|
||||||
|
QWindow *window = QWindowsAccessibility::windowHelper(iface);
|
||||||
delete iface;
|
delete iface;
|
||||||
|
|
||||||
if (!window) {
|
if (!window) {
|
||||||
|
@ -205,6 +205,7 @@ QAccessibleWidget::QAccessibleWidget(QWidget *w, QAccessible::Role role, const Q
|
|||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QWindow *QAccessibleWidget::window() const
|
QWindow *QAccessibleWidget::window() const
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(widget());
|
||||||
return widget()->windowHandle();
|
return widget()->windowHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +344,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
|
|||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QAccessibleInterface *QAccessibleWidget::parent() const
|
QAccessibleInterface *QAccessibleWidget::parent() const
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(widget());
|
||||||
QObject *parentWidget= widget()->parentWidget();
|
QObject *parentWidget= widget()->parentWidget();
|
||||||
if (!parentWidget)
|
if (!parentWidget)
|
||||||
parentWidget = qApp;
|
parentWidget = qApp;
|
||||||
@ -352,6 +354,7 @@ QAccessibleInterface *QAccessibleWidget::parent() const
|
|||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QAccessibleInterface *QAccessibleWidget::child(int index) const
|
QAccessibleInterface *QAccessibleWidget::child(int index) const
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(widget());
|
||||||
QWidgetList childList = childWidgets(widget());
|
QWidgetList childList = childWidgets(widget());
|
||||||
if (index >= 0 && index < childList.size())
|
if (index >= 0 && index < childList.size())
|
||||||
return QAccessible::queryAccessibleInterface(childList.at(index));
|
return QAccessible::queryAccessibleInterface(childList.at(index));
|
||||||
|
@ -364,6 +364,24 @@ void tst_QAccessibility::eventTest()
|
|||||||
QVERIFY(QTestAccessibility::containsEvent(&hideEvent));
|
QVERIFY(QTestAccessibility::containsEvent(&hideEvent));
|
||||||
|
|
||||||
delete button;
|
delete button;
|
||||||
|
|
||||||
|
// Make sure that invalid events don't bring down the system
|
||||||
|
// these events can be in user code.
|
||||||
|
QWidget *widget = new QWidget();
|
||||||
|
QAccessibleEvent ev1(widget, QAccessible::Focus);
|
||||||
|
QAccessible::updateAccessibility(&ev1);
|
||||||
|
|
||||||
|
QAccessibleEvent ev2(widget, QAccessible::Focus);
|
||||||
|
ev2.setChild(7);
|
||||||
|
QAccessible::updateAccessibility(&ev2);
|
||||||
|
delete widget;
|
||||||
|
|
||||||
|
QObject *object = new QObject();
|
||||||
|
QAccessibleEvent ev3(widget, QAccessible::Focus);
|
||||||
|
QAccessible::updateAccessibility(&ev3);
|
||||||
|
delete object;
|
||||||
|
|
||||||
|
QTestAccessibility::clearEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user