summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-04-08 15:34:51 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-04-11 08:44:39 (GMT)
commitb033bb91ea6fd32989cc59904aa79db9a188bf5b (patch)
tree9d8fafe53ed61130c07afb98546dfe1a9b3de49f /tests
parent32372616ed942685c7367d6aee58a7fd3849cc0b (diff)
downloadQt-b033bb91ea6fd32989cc59904aa79db9a188bf5b.zip
Qt-b033bb91ea6fd32989cc59904aa79db9a188bf5b.tar.gz
Qt-b033bb91ea6fd32989cc59904aa79db9a188bf5b.tar.bz2
Make sure removed QTextBlock is invalid
If the block is removed from document block map, we will mark the right node to the current head->freelist index, but it shouldn't be accessed directly, otherwise it can cause crash because of uninitialized node. Hence we need to check if a node index is equal to current freelist index. If so, it cannot be a valid block. Task-number: QTBUG-18500 Reviewed-by: Eskil
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextblock/tst_qtextblock.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp
index cec3a6a..748d921 100644
--- a/tests/auto/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/qtextblock/tst_qtextblock.cpp
@@ -76,6 +76,7 @@ private slots:
void excludeParagraphSeparatorFragment();
void backwardsBlockIterator();
void previousBlock_qtbug18026();
+ void removedBlock_qtbug18500();
private:
QTextDocument *doc;
@@ -181,5 +182,16 @@ void tst_QTextBlock::previousBlock_qtbug18026()
QVERIFY(last.isValid());
}
+void tst_QTextBlock::removedBlock_qtbug18500()
+{
+ cursor.insertText("line 1\nline 2\nline 3 \nline 4\n");
+ cursor.setPosition(7);
+ QTextBlock block = cursor.block();
+ cursor.setPosition(21, QTextCursor::KeepAnchor);
+
+ cursor.removeSelectedText();
+ QVERIFY(!block.isValid());
+}
+
QTEST_MAIN(tst_QTextBlock)
#include "tst_qtextblock.moc"