summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qcompleter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/util/qcompleter.cpp')
-rw-r--r--src/gui/util/qcompleter.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 05fe744..1abc2d9 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -532,17 +532,22 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con
QMatchData old = cache[parent].take(part);
cost = cost + m.indices.cost() - old.indices.cost();
if (cost * sizeof(int) > 1024 * 1024) {
- QMap<QModelIndex, CacheItem>::iterator it1 ;
- for (it1 = cache.begin(); it1 != cache.end(); ++it1) {
+ QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin();
+ while (it1 != cache.end()) {
CacheItem& ci = it1.value();
int sz = ci.count()/2;
QMap<QString, QMatchData>::iterator it2 = ci.begin();
- for (int i = 0; it2 != ci.end() && i < sz; i++, ++it2) {
+ int i = 0;
+ while (it2 != ci.end() && i < sz) {
cost -= it2.value().indices.cost();
- ci.erase(it2);
+ it2 = ci.erase(it2);
+ i++;
+ }
+ if (ci.count() == 0) {
+ it1 = cache.erase(it1);
+ } else {
+ ++it1;
}
- if (ci.count() == 0)
- cache.erase(it1);
}
}
@@ -1808,7 +1813,7 @@ QStringList QCompleter::splitPath(const QString& path) const
This signal is sent when an item in the popup() is highlighted by
the user. It is also sent if complete() is called with the completionMode()
- set to QCOmpleter::InlineCompletion. The item's \a text is given.
+ set to QCompleter::InlineCompletion. The item's \a text is given.
*/
QT_END_NAMESPACE