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

List:       kde-commits
Subject:    [koffice] plugins/textshape: Make erasing iterator-safe in
From:       "Dr. Robert Marmorstein" <robert () narnia ! homeunix ! com>
Date:       2011-08-02 9:16:39
Message-ID: 20110802091639.92849A60DA () git ! kde ! org
[Download RAW message or body]

Git commit 4e39c7e25c2a09e73f2d32db3c3fd416c9230cf0 by Dr. Robert Marmorstein.
Committed on 01/08/2011 at 20:45.
Pushed by robertm into branch 'master'.

Make erasing iterator-safe in textshape layout.

This may or may not be causing problems now, but it doesn't
hurt to do it right.

M  +6    -5    plugins/textshape/Layout.cpp

http://commits.kde.org/koffice/4e39c7e25c2a09e73f2d32db3c3fd416c9230cf0

diff --git a/plugins/textshape/Layout.cpp b/plugins/textshape/Layout.cpp
index b82a649..4a0ca50 100644
--- a/plugins/textshape/Layout.cpp
+++ b/plugins/textshape/Layout.cpp
@@ -525,12 +525,13 @@ bool Layout::nextParag()
     // first remove any drop-caps related formatting that's already there in the layout.
     // we'll do it all afresh now.
     QList<QTextLayout::FormatRange> formatRanges = layout->additionalFormats();
-    for (QList< QTextLayout::FormatRange >::Iterator iter = formatRanges.begin();
-            iter != formatRanges.end();
-            ++iter) {
-        if (iter->format.boolProperty(DropCapsAdditionalFormattingId)) {
-            formatRanges.erase(iter);
+    QList< QTextLayout::FormatRange >::Iterator iter = formatRanges.begin();
+    while (iter != formatRanges.end()) {
+        if (iter->format.boolProperty(DropCapsAdditionalFormattingId)){
+            iter = formatRanges.erase(iter);
         }
+        else
+           ++iter;
     }
     if (formatRanges.count() != layout->additionalFormats().count())
         layout->setAdditionalFormats(formatRanges);


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

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