Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
4.7.4, 4.8.x, 5.6.0
-
None
-
Linux x64
Tested with Qt 4.7.4 and 4.8-git
Description
for the following example:
#include <QApplication> #include <QTextDocument> #include <QTextCursor> #include <QTextBlock> #include <QDebug> void dump_doc(QTextDocument *document) { QTextBlock b(document->firstBlock()); while (b.isValid()) { qDebug() /*<< "position" << b.position()*/ /*<< "length" << b.length()*/ << "blockNumber" << b.blockNumber() << "userState" << b.userState() << "text" << b.text() ; b = b.next(); }; } int main(int argc, char **argv) { QApplication app(argc, argv); QTextDocument doc; QTextBlock lastBlock; { QTextCursor cur(&doc); cur.insertBlock(); cur.insertText("Hello"); cur.insertBlock(); cur.insertText("World!"); cur.block().setUserState(1); lastBlock = cur.block(); } dump_doc(&doc); qDebug(); { QTextCursor cur(lastBlock); cur.select(QTextCursor::BlockUnderCursor); cur.removeSelectedText(); } dump_doc(&doc); return 0; }
the output is:
blockNumber 0 userState -1 text "" blockNumber 1 userState -1 text "Hello" blockNumber 2 userState 1 text "World!" blockNumber 0 userState -1 text "" blockNumber 1 userState 1 text "Hello"
First it has 3 Textblock and only the last "World!"-block has the userState 1, everything correct.
But now if we delete the last userState Block, the "Hello"-block suddenly gets the userState 1, which is wrong, it should still be -1.
So in short, the expected output should be
blockNumber 0 userState -1 text ""
blockNumber 1 userState -1 text "Hello"