forked from qt-creator/qt-creator
Wizards: Fix crash
... if the project has no classes. Apparently, one must not call QFutureInterface::reportsResults() with an empty list, so prevent that. Also, for simplicity, make sure we have only one possible point of deletion for the watcher. Change-Id: I68c3813459533ced86610e88bea81b6a9d170ca5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -632,7 +632,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
||||
if (!classesFilter)
|
||||
return;
|
||||
classesFilter->prepareSearch({});
|
||||
const auto watcher = new QFutureWatcher<LocatorFilterEntry>(lineEdit);
|
||||
const auto watcher = new QFutureWatcher<LocatorFilterEntry>;
|
||||
const auto handleResults = [this, lineEdit, watcher](int firstIndex, int endIndex) {
|
||||
QSet<QString> 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<LocatorFilterEntry>::resultsReadyAt, lineEdit,
|
||||
handleResults);
|
||||
QObject::connect(watcher, &QFutureWatcher<LocatorFilterEntry>::finished,
|
||||
watcher, &QFutureWatcher<LocatorFilterEntry>::deleteLater);
|
||||
watcher->setFuture(runAsync([classesFilter](QFutureInterface<LocatorFilterEntry> &f) {
|
||||
const QList<LocatorFilterEntry> matches = classesFilter->matchesFor(f, {});
|
||||
f.reportResults(QVector<LocatorFilterEntry>(matches.cbegin(), matches.cend()));
|
||||
if (!matches.isEmpty())
|
||||
f.reportResults(QVector<LocatorFilterEntry>(matches.cbegin(), matches.cend()));
|
||||
f.reportFinished();
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user