forked from qt-creator/qt-creator
JsonFieldPage: Fix collecting the results from all matchers
Connect to LocatorMatcher::done() signal instead of to
serialOutputDataReady() in order to get all the results
available (not just 1st partial results).
Give locator matcher a parent to avoid possible leak.
Amends 1cc7342ef1
Change-Id: Ie4a73a5b2dd25f22616bd30a13eb7393c96a890f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -599,10 +599,14 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
||||
using namespace Utils;
|
||||
if (m_completion == Completion::None)
|
||||
return;
|
||||
const auto handleResults = [this, lineEdit](const LocatorFilterEntries &entries) {
|
||||
LocatorMatcher *matcher = new LocatorMatcher;
|
||||
matcher->setParent(lineEdit);
|
||||
matcher->setTasks(LocatorMatcher::matchers(MatcherType::Classes));
|
||||
const auto handleResults = [lineEdit, matcher, completion = m_completion] {
|
||||
QSet<QString> namespaces;
|
||||
QStringList classes;
|
||||
Project * const project = ProjectTree::currentProject();
|
||||
const LocatorFilterEntries entries = matcher->outputData();
|
||||
for (const LocatorFilterEntry &entry : entries) {
|
||||
static const auto isReservedName = [](const QString &name) {
|
||||
static const QRegularExpression rx1("^_[A-Z].*");
|
||||
@@ -623,7 +627,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
||||
if (hasNamespace) {
|
||||
if (isBaseClassCandidate)
|
||||
classes << (entry.extraInfo + "::" + entry.displayName);
|
||||
if (m_completion == Completion::Namespaces) {
|
||||
if (completion == Completion::Namespaces) {
|
||||
if (!project
|
||||
|| entry.filePath.startsWith(project->projectDirectory().toString())) {
|
||||
namespaces << entry.extraInfo;
|
||||
@@ -632,7 +636,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
||||
}
|
||||
}
|
||||
QStringList completionList;
|
||||
if (m_completion == Completion::Namespaces) {
|
||||
if (completion == Completion::Namespaces) {
|
||||
completionList = toList(namespaces);
|
||||
completionList = filtered(completionList, [&classes](const QString &ns) {
|
||||
return !classes.contains(ns);
|
||||
@@ -646,9 +650,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
||||
completionList.sort();
|
||||
lineEdit->setSpecialCompleter(new QCompleter(completionList, lineEdit));
|
||||
};
|
||||
LocatorMatcher *matcher = new LocatorMatcher;
|
||||
matcher->setTasks(LocatorMatcher::matchers(MatcherType::Classes));
|
||||
QObject::connect(matcher, &LocatorMatcher::serialOutputDataReady, lineEdit, handleResults);
|
||||
QObject::connect(matcher, &LocatorMatcher::done, lineEdit, handleResults);
|
||||
QObject::connect(matcher, &LocatorMatcher::done, matcher, &QObject::deleteLater);
|
||||
matcher->start();
|
||||
}
|
||||
|
Reference in New Issue
Block a user