diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index 6fe2f713745..4d0a89a08f9 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -89,12 +89,8 @@ void HelpIndexFilter::prepareSearch(const QString &entry) QList HelpIndexFilter::matchesFor(QFutureInterface &future, const QString &entry) { - m_mutex.lock(); // guard m_needsUpdate - bool forceUpdate = m_needsUpdate; - m_mutex.unlock(); - - if (forceUpdate || m_searchTermCache.size() < 2 || m_searchTermCache.isEmpty() - || !entry.contains(m_searchTermCache)) { + if (m_needsUpdate.exchange(false) || m_searchTermCache.size() < 2 + || m_searchTermCache.isEmpty() || !entry.contains(m_searchTermCache)) { int limit = entry.size() < 2 ? 200 : INT_MAX; QSet results; for (const QString &filePath : qAsConst(m_helpDatabases)) { @@ -108,9 +104,6 @@ QList HelpIndexFilter::matchesFor(QFutureInterface &future, QList HelpIndexFilter::matchesFor(QFutureInterface &future, const QString &entry) { - if (m_needsUpdate) { + if (m_needsUpdate.exchange(false)) { QStringList indices; QMetaObject::invokeMethod(this, [this] { return allIndices(); }, Qt::BlockingQueuedConnection, &indices); - m_needsUpdate = false; m_allIndicesCache = indices; // force updating the cache taking the m_allIndicesCache m_lastIndicesCache = QStringList();