diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-10 15:17:14 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-10 15:42:15 (GMT) |
commit | 1b326932d48c0e584f9d5173fa5f892c5086fee8 (patch) | |
tree | 6963f0261f22684ad7c793f8c6cd8cc7401513cd | |
parent | 09ff8924d5d05b285d9ed6a03817bdf271b6b108 (diff) | |
download | Qt-1b326932d48c0e584f9d5173fa5f892c5086fee8.zip Qt-1b326932d48c0e584f9d5173fa5f892c5086fee8.tar.gz Qt-1b326932d48c0e584f9d5173fa5f892c5086fee8.tar.bz2 |
Not requiring valid QTextBlock in previous()
Commit 64852122ba7 introduced a regression in QTextBlock::previous(),
programs that do doc.end().previous() will not be able to retrieve
the last valid block. Revert this change so that we can keep the
behavior consistent with previous versions.
Task-number: QTBUG-18026
Reviewed-by: Eskil
-rw-r--r-- | src/gui/text/qtextobject.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qtextblock/tst_qtextblock.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index e323fd0..94f2fc7 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -1504,7 +1504,7 @@ QTextBlock QTextBlock::next() const */ QTextBlock QTextBlock::previous() const { - if (!isValid()) + if (!p) return QTextBlock(); return QTextBlock(p, p->blockMap().previous(n)); diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp index 7b41874..cec3a6a 100644 --- a/tests/auto/qtextblock/tst_qtextblock.cpp +++ b/tests/auto/qtextblock/tst_qtextblock.cpp @@ -75,6 +75,7 @@ private slots: void fragmentOverBlockBoundaries(); void excludeParagraphSeparatorFragment(); void backwardsBlockIterator(); + void previousBlock_qtbug18026(); private: QTextDocument *doc; @@ -174,5 +175,11 @@ void tst_QTextBlock::backwardsBlockIterator() QCOMPARE(it.fragment().position(), 0); } +void tst_QTextBlock::previousBlock_qtbug18026() +{ + QTextBlock last = doc->end().previous(); + QVERIFY(last.isValid()); +} + QTEST_MAIN(tst_QTextBlock) #include "tst_qtextblock.moc" |