summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-07-02 13:07:36 +0200
committermae <qt-info@nokia.com>2010-07-02 13:20:05 +0200
commit62db6c18c7f1f60819783ed5e1340e9fc09e072e (patch)
treeb04393a2a539c0a0bbef774f589d61a4df96f378 /src/gui/text/qtextdocument_p.cpp
parent0c86cb8c29b3212cef3227cf7519d347c997b9d7 (diff)
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
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index f3cd48157f..a55e5f364c 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;