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

List:       kde-commits
Subject:    [cantor/frameworks] src: fix crash when highlighting a new entry
From:       Alexander Rieder <alexanderrieder () gmail ! com>
Date:       2014-12-28 23:39:35
Message-ID: E1Y5NQt-0003nm-Rc () scm ! kde ! org
[Download RAW message or body]

Git commit cae622f1ee159f91089563861adcfaf4e87aafa3 by Alexander Rieder.
Committed on 28/12/2014 at 23:40.
Pushed by arieder into branch 'frameworks'.

fix crash when highlighting a new entry

M  +7    -0    src/worksheet.cpp

http://commits.kde.org/cantor/cae622f1ee159f91089563861adcfaf4e87aafa3

diff --git a/src/worksheet.cpp b/src/worksheet.cpp
index 310e00c..9ff8cf1 100644
--- a/src/worksheet.cpp
+++ b/src/worksheet.cpp
@@ -689,11 +689,13 @@ void Worksheet::highlightItem(WorksheetTextItem* item)
     QList<QList<QTextLayout::FormatRange> > formats;
 
     if (oldDocument)
+    {
         for (QTextBlock b = oldDocument->firstBlock();
              b.isValid(); b = b.next())
         {
             formats.append(b.layout()->additionalFormats());
         }
+    }
 
     // Not every highlighter is a Cantor::DefaultHighligther (e.g. the
     // highlighter for KAlgebra)
@@ -705,12 +707,17 @@ void Worksheet::highlightItem(WorksheetTextItem* item)
     }
 
     if (oldDocument)
+    {
+        QTextCursor cursor(oldDocument);
+        cursor.beginEditBlock();
         for (QTextBlock b = oldDocument->firstBlock();
              b.isValid(); b = b.next())
         {
             b.layout()->setAdditionalFormats(formats.first());
             formats.pop_front();
         }
+        cursor.endEditBlock();
+    }
 
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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