summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtexttable/tst_qtexttable.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2010-07-07 14:06:11 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2010-07-07 14:06:11 (GMT)
commitf91a2789c385af25310ac5f0463d5bb3311ec089 (patch)
tree959e7b6910091349050e9bdd986ef4f676502767 /tests/auto/qtexttable/tst_qtexttable.cpp
parent2d298f468fa80003386aeb7304274659153923a3 (diff)
downloadQt-f91a2789c385af25310ac5f0463d5bb3311ec089.zip
Qt-f91a2789c385af25310ac5f0463d5bb3311ec089.tar.gz
Qt-f91a2789c385af25310ac5f0463d5bb3311ec089.tar.bz2
Fix crash when removing columns in merged row
Change 4b709b41f5a7ae8dc6e537b644158f5201ce0a98 tried to make sure that rows with merged cells would not be completely removed, as this would cause a crash. However, when removing just a few columns from a merged cell, the span of the cell should be reduced by the number of columns removed. The "touched" guard would cause the span to be decreased a maximum of one time, regardless of how many columns were removed, leaving the table in an invalid state, as the column count would be smaller than the span of the cell. This would assert later on. To avoid this, we only guard against removal, not against decreasing the span. Task-number: QTBUG-11646 Reviewed-by: Thomas Zander
Diffstat (limited to 'tests/auto/qtexttable/tst_qtexttable.cpp')
-rw-r--r--tests/auto/qtexttable/tst_qtexttable.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp
index 2e6007e..c6ead5a 100644
--- a/tests/auto/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/qtexttable/tst_qtexttable.cpp
@@ -93,6 +93,7 @@ private slots:
void removeColumns3();
void removeColumns4();
void removeColumns5();
+ void removeColumnsInTableWithMergedRows();
private:
QTextTable *create2x2Table();
@@ -931,5 +932,18 @@ void tst_QTextTable::removeColumns5()
QCOMPARE(table->cellAt(3, 2).firstPosition(), 11);
}
+void tst_QTextTable::removeColumnsInTableWithMergedRows()
+{
+ QTextTable *table = cursor.insertTable(3, 4);
+ table->mergeCells(0, 0, 1, 4);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 4);
+
+ table->removeColumns(0, table->columns() - 1);
+
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 1);
+}
+
QTEST_MAIN(tst_QTextTable)
#include "tst_qtexttable.moc"