summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2012-09-06 08:50:43 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-09-07 12:29:58 (GMT)
commit2df3a87d1013c38e9aa8d90b6f2a5552bf88aaf4 (patch)
treee168afa319023d6bb50e1d51a9c5946d8185e9d9
parentc7d5071afc6c76925c90ff35041dc4eb86511271 (diff)
downloadQt-2df3a87d1013c38e9aa8d90b6f2a5552bf88aaf4.zip
Qt-2df3a87d1013c38e9aa8d90b6f2a5552bf88aaf4.tar.gz
Qt-2df3a87d1013c38e9aa8d90b6f2a5552bf88aaf4.tar.bz2
Revert "Speed up QTextEngine::resolveAdditionalFormats"v4.8.3
This reverts commit 49fbb6e14af78f751fa114c3cf986aaa607d7408 which introduced crashes e.g. in Qt Creator. Since the original change was an optimization, it is reverted in the Qt 4.8 branch since stability is the main priority there. The crash has been fixed for the corresponding Qt 5 commit. It would be an option to recommit the optimization and the crash fix to a future minor release of Qt 4. Task-number: QTBUG-27140 Change-Id: I9dc959ea252fe55a22fd90f333ccb335b3ef1311 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/gui/text/qtextengine.cpp67
1 files changed, 2 insertions, 65 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index bb453d5..366b5bf 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2801,25 +2801,6 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
return tabWidth;
}
-namespace {
-class FormatRangeComparatorByStart {
- const QList<QTextLayout::FormatRange> &list;
-public:
- FormatRangeComparatorByStart(const QList<QTextLayout::FormatRange> &list) : list(list) { }
- bool operator()(int a, int b) {
- return list.at(a).start < list.at(b).start;
- }
-};
-class FormatRangeComparatorByEnd {
- const QList<QTextLayout::FormatRange> &list;
-public:
- FormatRangeComparatorByEnd(const QList<QTextLayout::FormatRange> &list) : list(list) { }
- bool operator()(int a, int b) {
- return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
- }
-};
-}
-
void QTextEngine::resolveAdditionalFormats() const
{
if (!specialData || specialData->addFormats.isEmpty()
@@ -2831,53 +2812,9 @@ void QTextEngine::resolveAdditionalFormats() const
specialData->resolvedFormatIndices.clear();
QVector<int> indices(layoutData->items.count());
-
-
- QVarLengthArray<int, 64> addFormatSortedByStart;
- addFormatSortedByStart.reserve(specialData->addFormats.count());
- for (int i = 0; i < specialData->addFormats.count(); ++i)
- addFormatSortedByStart.append(i);
- QVarLengthArray<int, 64> addFormatSortedByEnd = addFormatSortedByStart;
- qSort(addFormatSortedByStart.begin(), addFormatSortedByStart.end(),
- FormatRangeComparatorByStart(specialData->addFormats));
- qSort(addFormatSortedByEnd.begin(), addFormatSortedByEnd.end(),
- FormatRangeComparatorByEnd(specialData->addFormats));
-
- QVarLengthArray<int, 16> currentFormats;
- const int *startIt = addFormatSortedByStart.constBegin();
- const int *endIt = addFormatSortedByEnd.constBegin();
-
for (int i = 0; i < layoutData->items.count(); ++i) {
- const QScriptItem *si = &layoutData->items.at(i);
- int end = si->position + length(si);
-
- while (startIt != addFormatSortedByStart.end() &&
- specialData->addFormats.at(*startIt).start <= si->position) {
- currentFormats.insert(qUpperBound(currentFormats.begin(), currentFormats.end(), *startIt),
- *startIt);
- ++startIt;
- }
- while (endIt != addFormatSortedByEnd.end() &&
- specialData->addFormats.at(*endIt).start + specialData->addFormats.at(*endIt).length < end) {
- currentFormats.remove(qBinaryFind(currentFormats, *endIt) - currentFormats.begin());
- ++endIt;
- }
- QTextCharFormat format;
- const QTextFormatCollection *formats = 0;
- if (block.docHandle()) {
- formats = this->formats();
- format = formats->charFormat(formatIndex(si));
- }
- foreach (int cur, currentFormats) {
- const QTextLayout::FormatRange &r = specialData->addFormats.at(cur);
- Q_ASSERT (r.start <= si->position && r.start + r.length >= end);
- if (!specialData->addFormatIndices.isEmpty()) {
- format.merge(formats->format(specialData->addFormatIndices.at(cur)));
- } else {
- format.merge(r.format);
- }
- }
- indices[i] = collection->indexForFormat(format);
+ QTextCharFormat f = format(&layoutData->items.at(i));
+ indices[i] = collection->indexForFormat(f);
}
specialData->resolvedFormatIndices = indices;
}