Editor: fix crash after triggering select all with no search results

Change-Id: I32d5172e8b5df6db93053f358c5a72cb8d38f6ea
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2022-02-17 15:56:36 +01:00
parent d487110351
commit 088d692bb2

View File

@@ -857,7 +857,10 @@ void TextEditorWidgetFind::selectAll(const QString &txt, FindFlags findFlags)
m_selectWatcher = new QFutureWatcher<FileSearchResultList>();
connect(m_selectWatcher, &QFutureWatcher<Utils::FileSearchResultList>::finished,
this, [this]() {
const FileSearchResultList &results = m_selectWatcher->result();
const QFuture<FileSearchResultList> future = m_selectWatcher->future();
if (future.resultCount() <= 0)
return;
const FileSearchResultList &results = future.result();
const QTextCursor c(m_editor->document());
auto cursorForResult = [c](const FileSearchResult &r) {
return Utils::Text::selectAt(c, r.lineNumber, r.matchStart + 1, r.matchLength);