diff options
author | mae <qt-info@nokia.com> | 2010-07-02 11:07:36 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-07-02 11:20:05 (GMT) |
commit | 62db6c18c7f1f60819783ed5e1340e9fc09e072e (patch) | |
tree | b04393a2a539c0a0bbef774f589d61a4df96f378 | |
parent | 0c86cb8c29b3212cef3227cf7519d347c997b9d7 (diff) | |
download | Qt-62db6c18c7f1f60819783ed5e1340e9fc09e072e.zip Qt-62db6c18c7f1f60819783ed5e1340e9fc09e072e.tar.gz Qt-62db6c18c7f1f60819783ed5e1340e9fc09e072e.tar.bz2 |
Fix exponential behavior of QTextCursor::removeSelectedText
removeSelectedText adjusts all other cursors for every fragment
and block which gets removed. This becomes (for reasons yet
to be understood) exponential with loads of cursors (something
creator has for the semantic highlighting).
Done-with: Roberto Raggi
Reviewed-by: Simon Hausmann
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 7 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index f3cd481..a55e5f3 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -205,6 +205,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() undoEnabled = true; inContentsChange = false; + inRemove = false; defaultTextOption.setTabStop(80); // same as in qtextengine.cpp defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@ -669,7 +670,10 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati { if (length == 0) return; + inRemove = true; move(pos, -1, length, op); + inRemove = false; + adjustDocumentChangesAndCursors(pos, -length, op); } void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode) @@ -1263,6 +1267,9 @@ void QTextDocumentPrivate::documentChange(int from, int length) */ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op) { + if (inRemove) // postpone, will be called again from QTextDocumentPrivate::remove() + return; + if (!editBlock) ++revision; diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index d1bd698..06e0753 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -346,6 +346,7 @@ public: int maximumBlockCount; uint needsEnsureMaximumBlockCount : 1; uint inContentsChange : 1; + uint inRemove : 1; QSizeF pageSize; QString title; QString url; |