forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ private:
|
||||
|
||||
void coreAboutToClose() override;
|
||||
|
||||
QString m_sshPrompt;
|
||||
bool m_preventRepositoryChanged;
|
||||
VcsOutputWindow *m_outputWindow = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user