Fix potential division by zero

Since it's possible to call the function on an
empty model, return failure in that case.

Change-Id: I0a0eabe917da3e6294bdd616a85579f6dc894ec8
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
bb10
Frederik Gladhorn 2013-08-17 16:51:27 +02:00 committed by The Qt Project
parent 7495b59dbd
commit 6a040d5c81
1 changed files with 13 additions and 8 deletions

View File

@ -2230,16 +2230,21 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString
int index = message.arguments().at(0).toInt();
bool success = false;
int row, col, rowExtents, colExtents;
bool isSelected;
int row = -1;
int col = -1;
int rowExtents = -1;
int colExtents = -1;
bool isSelected = false;
int cols = interface->tableInterface()->columnCount();
row = index/cols;
col = index%cols;
QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface();
if (cell) {
cell->rowColumnExtents(&row, &col, &rowExtents, &colExtents, &isSelected);
success = true;
if (cols > 0) {
row = index / cols;
col = index % cols;
QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface();
if (cell) {
cell->rowColumnExtents(&row, &col, &rowExtents, &colExtents, &isSelected);
success = true;
}
}
QVariantList list;