forked from qt-creator/qt-creator
Don't call non-const methods on temporary QList
Otherwise it may unnecessarily detach. Either store a local const reference or call const equivalent (e.g. constFirst()). Change-Id: I96d665487cf28c17e72bea17f1b8f164ce06cc70 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -281,13 +281,14 @@ QFuture<FileSearchResultList> GitGrep::executeSearch(const TextEditor::FileFindP
|
||||
IEditor *GitGrep::openEditor(const SearchResultItem &item,
|
||||
const TextEditor::FileFindParameters ¶meters)
|
||||
{
|
||||
GitGrepParameters params = parameters.searchEngineParameters.value<GitGrepParameters>();
|
||||
if (params.ref.isEmpty() || item.path().isEmpty())
|
||||
const GitGrepParameters params = parameters.searchEngineParameters.value<GitGrepParameters>();
|
||||
const QStringList &itemPath = item.path();
|
||||
if (params.ref.isEmpty() || itemPath.isEmpty())
|
||||
return nullptr;
|
||||
const QString path = QDir::fromNativeSeparators(item.path().first());
|
||||
const QString path = QDir::fromNativeSeparators(itemPath.first());
|
||||
const FilePath topLevel = FilePath::fromString(parameters.additionalParameters.toString());
|
||||
IEditor *editor = m_client->openShowEditor(
|
||||
topLevel, params.ref, path, GitClient::ShowEditor::OnlyIfDifferent);
|
||||
IEditor *editor = m_client->openShowEditor(topLevel, params.ref, path,
|
||||
GitClient::ShowEditor::OnlyIfDifferent);
|
||||
if (editor)
|
||||
editor->gotoLine(item.mainRange().begin.line, item.mainRange().begin.column);
|
||||
return editor;
|
||||
|
||||
Reference in New Issue
Block a user