GitGrep: Do not access global state from non-main thread

- VcsCommand calls into VcsOutputWindow at construction, so we need to
  construct it in the main thread
- VcsCommand may not call into global settings from runCommand, so we
  need to store the ssh prompt command
- accessing the GitClient singleton in a non-main thread is not
  thread-safe

Change-Id: I3dcdff8091c2dcea1c165ce5b3eca5ef62d474fd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Eike Ziller
2021-06-07 12:23:19 +02:00
parent 93fcf5c91f
commit ee61b09b21
3 changed files with 29 additions and 30 deletions

View File

@@ -43,6 +43,7 @@ VcsCommand::VcsCommand(const QString &workingDirectory, const Environment &envir
VcsOutputWindow::setRepository(workingDirectory);
setDisableUnixTerminal();
m_outputWindow = VcsOutputWindow::instance();
m_sshPrompt = VcsBase::sshPrompt();
connect(this, &VcsCommand::started, this, [this] {
if (flags() & ExpectRepoChanges)
@@ -57,7 +58,7 @@ VcsCommand::VcsCommand(const QString &workingDirectory, const Environment &envir
const Environment VcsCommand::processEnvironment() const
{
Environment env = Core::ShellCommand::processEnvironment();
VcsBase::setProcessEnvironment(&env, flags() & ForceCLocale, VcsBase::sshPrompt());
VcsBase::setProcessEnvironment(&env, flags() & ForceCLocale, m_sshPrompt);
return env;
}

View File

@@ -63,6 +63,7 @@ private:
void coreAboutToClose() override;
QString m_sshPrompt;
bool m_preventRepositoryChanged;
VcsOutputWindow *m_outputWindow = nullptr;
};