a11y atspi: Add null checks in table iface methods
Add null checks to cover the cases where QAccessibleTableInterface::cellAt returns nullptr (which happens e.g. when called with invalid indices via AT-SPI) or where the cell object doesn't implement the QAccessibleTableCellInterface, which would previously result in crashes. Fixes: QTBUG-119167 Pick-to: 6.6 Change-Id: Ieb42617b32ca829af09ae1d54f5de9ec029e3ab2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit d91d53c951144255349e5d246353b598179ce967) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1f0c629a48
commit
10b480f1d8
@ -2694,16 +2694,17 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString
|
|||||||
if (cols > 0) {
|
if (cols > 0) {
|
||||||
row = index / cols;
|
row = index / cols;
|
||||||
col = index % cols;
|
col = index % cols;
|
||||||
QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface();
|
if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, col)) {
|
||||||
if (cell) {
|
if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface()) {
|
||||||
row = cell->rowIndex();
|
row = cellIface->rowIndex();
|
||||||
col = cell->columnIndex();
|
col = cellIface->columnIndex();
|
||||||
rowExtents = cell->rowExtent();
|
rowExtents = cellIface->rowExtent();
|
||||||
colExtents = cell->columnExtent();
|
colExtents = cellIface->columnExtent();
|
||||||
isSelected = cell->isSelected();
|
isSelected = cellIface->isSelected();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
list << success << row << col << rowExtents << colExtents << isSelected;
|
list << success << row << col << rowExtents << colExtents << isSelected;
|
||||||
connection.send(message.createReply(list));
|
connection.send(message.createReply(list));
|
||||||
@ -2711,12 +2712,22 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString
|
|||||||
} else if (function == "GetColumnExtentAt"_L1) {
|
} else if (function == "GetColumnExtentAt"_L1) {
|
||||||
int row = message.arguments().at(0).toInt();
|
int row = message.arguments().at(0).toInt();
|
||||||
int column = message.arguments().at(1).toInt();
|
int column = message.arguments().at(1).toInt();
|
||||||
connection.send(message.createReply(interface->tableInterface()->cellAt(row, column)->tableCellInterface()->columnExtent()));
|
int columnExtent = 0;
|
||||||
|
if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column)) {
|
||||||
|
if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
|
||||||
|
columnExtent = cellIface->columnExtent();
|
||||||
|
}
|
||||||
|
connection.send(message.createReply(columnExtent));
|
||||||
|
|
||||||
} else if (function == "GetRowExtentAt"_L1) {
|
} else if (function == "GetRowExtentAt"_L1) {
|
||||||
int row = message.arguments().at(0).toInt();
|
int row = message.arguments().at(0).toInt();
|
||||||
int column = message.arguments().at(1).toInt();
|
int column = message.arguments().at(1).toInt();
|
||||||
connection.send(message.createReply(interface->tableInterface()->cellAt(row, column)->tableCellInterface()->rowExtent()));
|
int rowExtent = 0;
|
||||||
|
if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column)) {
|
||||||
|
if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
|
||||||
|
rowExtent = cellIface->rowExtent();
|
||||||
|
}
|
||||||
|
connection.send(message.createReply(rowExtent));
|
||||||
|
|
||||||
} else if (function == "GetColumnHeader"_L1) {
|
} else if (function == "GetColumnHeader"_L1) {
|
||||||
int column = message.arguments().at(0).toInt();
|
int column = message.arguments().at(0).toInt();
|
||||||
@ -2756,8 +2767,12 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString
|
|||||||
} else if (function == "IsSelected"_L1) {
|
} else if (function == "IsSelected"_L1) {
|
||||||
int row = message.arguments().at(0).toInt();
|
int row = message.arguments().at(0).toInt();
|
||||||
int column = message.arguments().at(1).toInt();
|
int column = message.arguments().at(1).toInt();
|
||||||
QAccessibleTableCellInterface* cell = interface->tableInterface()->cellAt(row, column)->tableCellInterface();
|
bool selected = false;
|
||||||
connection.send(message.createReply(cell->isSelected()));
|
if (QAccessibleInterface* cell = interface->tableInterface()->cellAt(row, column)) {
|
||||||
|
if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
|
||||||
|
selected = cellIface->isSelected();
|
||||||
|
}
|
||||||
|
connection.send(message.createReply(selected));
|
||||||
} else if (function == "AddColumnSelection"_L1) {
|
} else if (function == "AddColumnSelection"_L1) {
|
||||||
int column = message.arguments().at(0).toInt();
|
int column = message.arguments().at(0).toInt();
|
||||||
connection.send(message.createReply(interface->tableInterface()->selectColumn(column)));
|
connection.send(message.createReply(interface->tableInterface()->selectColumn(column)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user