diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index 5c11d434006..9cfb13feac7 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -632,7 +632,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit) if (!classesFilter) return; classesFilter->prepareSearch({}); - const auto watcher = new QFutureWatcher(lineEdit); + const auto watcher = new QFutureWatcher; const auto handleResults = [this, lineEdit, watcher](int firstIndex, int endIndex) { QSet namespaces; QStringList classes; @@ -681,13 +681,15 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit) } completionList.sort(); lineEdit->setSpecialCompleter(new QCompleter(completionList, lineEdit)); - watcher->deleteLater(); }; QObject::connect(watcher, &QFutureWatcher::resultsReadyAt, lineEdit, handleResults); + QObject::connect(watcher, &QFutureWatcher::finished, + watcher, &QFutureWatcher::deleteLater); watcher->setFuture(runAsync([classesFilter](QFutureInterface &f) { const QList matches = classesFilter->matchesFor(f, {}); - f.reportResults(QVector(matches.cbegin(), matches.cend())); + if (!matches.isEmpty()) + f.reportResults(QVector(matches.cbegin(), matches.cend())); f.reportFinished(); })); }