[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/libs/kotext
From:       Thomas Zander <zander () kde ! org>
Date:       2010-11-07 14:17:41
Message-ID: 20101107141741.A77C7AC8A5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1193899 by zander:

Fix kword hangs when register changed is turned off

The previous implementation used the editor wide selection instead
of the registerTrackedChange() local selection and as such the bug report
exposed a recursively changing of formats over and over again.
Reimplementing a local looping fixes that by only looping over the
part we need to change AND by bypassing any register changes code from
withing itself.

BUG:244467

 M  +33 -1     KoTextEditor.cpp  


--- trunk/koffice/libs/kotext/KoTextEditor.cpp #1193898:1193899
@@ -331,7 +331,39 @@
 void KoTextEditor::registerTrackedChange(QTextCursor &selection, KoGenChange::Type \
changeType, QString title, QTextFormat& format, QTextFormat& prevFormat, bool \
applyToWholeBlock)  {
     if (!KoTextDocument(d->document).changeTracker() || \
                !KoTextDocument(d->document).changeTracker()->recordChanges()) {
-        d->clearCharFormatProperty(KoCharacterStyle::ChangeTrackerId);
+        // clear the ChangeTrackerId from the passed in selection, without \
recursively registring +        // change tracking again  ;)
+        int start = qMin(selection.position(), selection.anchor());
+        int end = qMax(selection.position(), selection.anchor());
+
+        QTextBlock block = selection.block();
+        if (block.position() > start)
+            block = block.document()->findBlock(start);
+
+        while (block.isValid() && block.position() < end) {
+            QTextBlock::iterator iter = block.begin();
+            while (! iter.atEnd()) {
+                QTextFragment fragment = iter.fragment();
+                if (fragment.position() > end)
+                    break;
+                if (fragment.position() + fragment.length() <= start) {
+                    iter++;
+                    continue;
+                }
+
+                QTextCursor cursor(block);
+                cursor.setPosition(fragment.position());
+                QTextCharFormat fm = cursor.charFormat();
+                fm.clearProperty(KoCharacterStyle::ChangeTrackerId);
+                int to = qMin(end, fragment.position() + fragment.length());
+                cursor.setPosition(to, QTextCursor::KeepAnchor);
+                cursor.setCharFormat(fm);
+                iter++;
+            }
+            block = block.next();
+        }
+
+
         return;
     }
 #ifndef NDEBUG


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic