summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-03-01 13:43:35 (GMT)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-03-02 09:59:18 (GMT)
commitb7a79ea08be3e127058be549ed354d6276e32e0f (patch)
tree7aa1f4330dfeeee56f4d7becc775df1d1f65d663 /src
parentb49eaedbe81011483ce52af71e9ebf29c61cef43 (diff)
downloadQt-b7a79ea08be3e127058be549ed354d6276e32e0f.zip
Qt-b7a79ea08be3e127058be549ed354d6276e32e0f.tar.gz
Qt-b7a79ea08be3e127058be549ed354d6276e32e0f.tar.bz2
minor optimization: ignore invalid preeditAreaPosition/preeditAreaText
Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 1dc8e23..d3db2a1 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -102,20 +102,22 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
const int preeditAreaStart = layout->preeditAreaPosition();
const int preeditAreaLength = layout->preeditAreaText().length();
- QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
- while (it != ranges.end()) {
- if (it->start >= preeditAreaStart
- && it->start + it->length <= preeditAreaStart + preeditAreaLength) {
- ++it;
- } else {
- it = ranges.erase(it);
+ if (preeditAreaLength != 0) {
+ QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
+ while (it != ranges.end()) {
+ if (it->start >= preeditAreaStart
+ && it->start + it->length <= preeditAreaStart + preeditAreaLength) {
+ ++it;
+ } else {
+ it = ranges.erase(it);
+ }
}
}
QTextCharFormat emptyFormat;
QTextLayout::FormatRange r;
- r.start = r.length = -1;
+ r.start = -1;
int i = 0;
while (i < formatChanges.count()) {
@@ -137,22 +139,26 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
r.length = i - r.start;
- if (r.start >= preeditAreaStart)
- r.start += preeditAreaLength;
- else if (r.start + r.length >= preeditAreaStart)
- r.length += preeditAreaLength;
+ if (preeditAreaLength != 0) {
+ if (r.start >= preeditAreaStart)
+ r.start += preeditAreaLength;
+ else if (r.start + r.length >= preeditAreaStart)
+ r.length += preeditAreaLength;
+ }
ranges << r;
- r.start = r.length = -1;
+ r.start = -1;
}
if (r.start != -1) {
r.length = formatChanges.count() - r.start;
- if (r.start >= preeditAreaStart)
- r.start += preeditAreaLength;
- else if (r.start + r.length >= preeditAreaStart)
- r.length += preeditAreaLength;
+ if (preeditAreaLength != 0) {
+ if (r.start >= preeditAreaStart)
+ r.start += preeditAreaLength;
+ else if (r.start + r.length >= preeditAreaStart)
+ r.length += preeditAreaLength;
+ }
ranges << r;
}