Fix empty locator results for search index

Make sure that we do not cache incomplete result lists when the search
is canceled (e.g. because the user typed another character).

Task-number: QTCREATORBUG-16753
Change-Id: I5a8f7ab54bed236ccd318841d95a3a4aa4106df0
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2016-08-29 10:32:18 +02:00
parent 3b35d39910
commit 365c1b7889

View File

@@ -87,6 +87,8 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
int limit = entry.size() < 2 ? 200 : INT_MAX; int limit = entry.size() < 2 ? 200 : INT_MAX;
QSet<QString> results; QSet<QString> results;
foreach (const QString &filePath, m_helpDatabases) { foreach (const QString &filePath, m_helpDatabases) {
if (future.isCanceled())
return QList<LocatorFilterEntry>();
QSet<QString> result; QSet<QString> result;
QMetaObject::invokeMethod(this, "searchMatches", Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(this, "searchMatches", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QSet<QString>, result), Q_RETURN_ARG(QSet<QString>, result),
@@ -111,7 +113,7 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
QSet<QString> allresults; QSet<QString> allresults;
foreach (const QString &keyword, m_keywordCache) { foreach (const QString &keyword, m_keywordCache) {
if (future.isCanceled()) if (future.isCanceled())
break; return QList<LocatorFilterEntry>();
if (keyword.startsWith(entry, cs)) { if (keyword.startsWith(entry, cs)) {
keywords.append(keyword); keywords.append(keyword);
allresults.insert(keyword); allresults.insert(keyword);