summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/text/qtexttable.cpp2
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp45
2 files changed, 46 insertions, 1 deletions
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 683ad8ac352..ff8644b5302 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -724,7 +724,7 @@ void QTextTable::insertColumns(int pos, int num)
if (i == d->nRows - 1 && pos == d->nCols) {
cell = d->fragment_end;
} else {
- int logicalGridIndexBeforePosition = pos > 0
+ int logicalGridIndexBeforePosition = pos > 0 || i > 0
? d->findCellIndex(d->grid[i*d->nCols + pos - 1])
: -1;
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index a7e319ef62e..f7e0f788f17 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -85,6 +85,8 @@ private slots:
void columnWidthWithImage();
#endif
+ void QTBUG138678_insertColumnAtStartWithRowspan();
+
private:
QTextTable *create2x2Table();
QTextTable *create4x4Table();
@@ -1413,6 +1415,49 @@ void tst_QTextTable::columnWidthWithImage()
}
#endif
+void tst_QTextTable::QTBUG138678_insertColumnAtStartWithRowspan()
+{
+ QString s =
+"<html><body>"
+"<table border=1>"
+"<tr>"
+" <td />"
+" <td />"
+" <td />"
+" <td />"
+" <td />"
+"</tr>"
+"<tr>"
+" <td rowspan=2 />"
+" <td rowspan=2 />"
+" <td />"
+" <td />"
+" <td rowspan=2 />"
+"</tr>"
+"<tr>"
+" <td />"
+" <td />"
+"</tr>"
+"</table></body></html>)";
+
+ QTextDocument doc;
+ doc.setHtml(s);
+
+ QTextEdit textEdit;
+ textEdit.setDocument(&doc);
+ textEdit.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&textEdit));
+
+ QTextCursor cursor(doc.firstBlock());
+ cursor.movePosition(QTextCursor::Right);
+
+ QTextTable *currentTable = cursor.currentTable();
+ QVERIFY(currentTable);
+
+ // Don't assert
+ currentTable->insertColumns(0, 1);
+}
+
QTEST_MAIN(tst_QTextTable)
#include "tst_qtexttable.moc"