diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-08 01:42:25 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-08 01:42:25 (GMT) |
commit | f65a93476422627342404f33a755ae543047eaed (patch) | |
tree | bc8bf7ce4170b568ce606031dc4ededab5d221fc | |
parent | 44277b86571d78f30f0d0393d01b11c672672ea2 (diff) | |
parent | f91a2789c385af25310ac5f0463d5bb3311ec089 (diff) | |
download | Qt-f65a93476422627342404f33a755ae543047eaed.zip Qt-f65a93476422627342404f33a755ae543047eaed.tar.gz Qt-f65a93476422627342404f33a755ae543047eaed.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Fix crash when removing columns in merged row
-rw-r--r-- | src/gui/text/qtexttable.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qtexttable/tst_qtexttable.cpp | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 5100176..ada18c8 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -915,12 +915,13 @@ void QTextTable::removeColumns(int pos, int num) for (int r = 0; r < d->nRows; ++r) { for (int c = pos; c < pos + num; ++c) { int cell = d->grid[r*d->nCols + c]; - if (touchedCells.contains(cell)) - continue; - touchedCells << cell; QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); QTextCharFormat fmt = collection->charFormat(it->format); int span = fmt.tableCellColumnSpan(); + if (touchedCells.contains(cell) && span <= 1) + continue; + touchedCells << cell; + if (span > 1) { fmt.setTableCellColumnSpan(span - 1); p->setCharFormat(it.position(), 1, fmt); 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" |