From 16100acdc9654c588a813f397d00d55bcf30bdc8 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 21 Apr 2023 10:19:53 +0200 Subject: [PATCH] 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 1cc7342ef16cf904915355de9ee88c0250bca852 Change-Id: Ie4a73a5b2dd25f22616bd30a13eb7393c96a890f Reviewed-by: Christian Kandeler --- .../projectexplorer/jsonwizard/jsonfieldpage.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index 2837fe844c8..49a95711893 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -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 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(); }