aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gitgrep.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-07-25 16:09:50 +0200
committerhjk <hjk@qt.io>2023-07-26 10:25:43 +0000
commit778a1d75ba9cf89ec009484ff8d8da28b59b54f1 (patch)
tree03270bf2c14cb5eefd84909a75562c2648d5e55f /src/plugins/git/gitgrep.cpp
parent8d5897b8eb7a753b38734fc6c1bde2cef873b768 (diff)
Git: Initialize GitClient on first access
This does not change the current timing of construction a lot as the GerritPlugin may need it immediately in some cases, in any case the gitGrep instance will need it. There's nothing big going on at destruction time, so the prolonged lifetime until really close to the end does not hurt. The reason here is that this way we will avoid cases like in change 5e5b90a9a1664c. Change-Id: I326d83c1a3d21114322ac6cce8d9e9b782faacdc Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/git/gitgrep.cpp')
-rw-r--r--src/plugins/git/gitgrep.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp
index b2e6e36a19d..c82226fa83b 100644
--- a/src/plugins/git/gitgrep.cpp
+++ b/src/plugins/git/gitgrep.cpp
@@ -135,8 +135,8 @@ static void runGitGrep(QPromise<SearchResultItems> &promise, const FileFindParam
const GitGrepParameters &gitParameters)
{
const auto setupProcess = [&parameters, gitParameters](Process &process) {
- const FilePath vcsBinary = GitClient::instance()->vcsBinary();
- const Environment environment = GitClient::instance()->processEnvironment();
+ const FilePath vcsBinary = gitClient().vcsBinary();
+ const Environment environment = gitClient().processEnvironment();
QStringList arguments = {
"-c", "color.grep.match=bold red",
@@ -189,7 +189,7 @@ static bool isGitDirectory(const FilePath &path)
return gitVc == VcsManager::findVersionControlForDirectory(path);
}
-GitGrep::GitGrep(GitClient *client)
+GitGrep::GitGrep()
{
m_widget = new QWidget;
auto layout = new QHBoxLayout(m_widget);
@@ -202,7 +202,7 @@ GitGrep::GitGrep(GitClient *client)
m_treeLineEdit->setValidator(new QRegularExpressionValidator(refExpression, this));
layout->addWidget(m_treeLineEdit);
// asynchronously check git version, add "recurse submodules" option if available
- Utils::onResultReady(client->gitVersion(), this,
+ Utils::onResultReady(gitClient().gitVersion(), this,
[this, pLayout = QPointer<QHBoxLayout>(layout)](unsigned version) {
if (version >= 0x021300 && pLayout) {
m_recurseSubmodules = new QCheckBox(Tr::tr("Recurse submodules"));
@@ -271,7 +271,7 @@ EditorOpener GitGrep::editorOpener() const
if (params.ref.isEmpty() || itemPath.isEmpty())
return nullptr;
const FilePath path = FilePath::fromUserInput(itemPath.first());
- IEditor *editor = GitClient::instance()->openShowEditor(
+ IEditor *editor = gitClient().openShowEditor(
parameters.searchDir, params.ref, path, GitClient::ShowEditor::OnlyIfDifferent);
if (editor)
editor->gotoLine(item.mainRange().begin.line, item.mainRange().begin.column);