diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp index 2c0cdee7337..05c515eabff 100644 --- a/src/libs/utils/shellcommand.cpp +++ b/src/libs/utils/shellcommand.cpp @@ -276,6 +276,7 @@ void ShellCommand::run(QFutureInterface &future) QString stdOut; QString stdErr; + emit started(); if (d->m_progressParser) d->m_progressParser->setFuture(&future); else diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h index c8bf38af111..eb3161e3a1e 100644 --- a/src/libs/utils/shellcommand.h +++ b/src/libs/utils/shellcommand.h @@ -154,6 +154,7 @@ public: signals: void stdOutText(const QString &); void stdErrText(const QString &); + void started(); void finished(bool ok, int exitCode, const QVariant &cookie); void success(const QVariant &cookie); diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 28542f7e5ec..f8222a36821 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -157,6 +157,7 @@ public: QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation. QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen). + bool m_postponeAutoReload = false; bool m_blockActivated = false; bool m_checkOnFocusChange = false; QString m_lastVisitedDirectory = QDir::currentPath(); @@ -597,6 +598,13 @@ void DocumentManager::unexpectFileChange(const QString &fileName) updateExpectedState(filePathKey(fileName, ResolveLinks)); } +void DocumentManager::setAutoReloadPostponed(bool postponed) +{ + d->m_postponeAutoReload = postponed; + if (!postponed) + QTimer::singleShot(500, m_instance, &DocumentManager::checkForReload); +} + static bool saveModifiedFilesHelper(const QList &documents, const QString &message, bool *cancelled, bool silently, const QString &alwaysSaveMessage, bool *alwaysSave, @@ -990,7 +998,7 @@ void DocumentManager::changedFile(const QString &fileName) void DocumentManager::checkForReload() { - if (d->m_changedFiles.isEmpty()) + if (d->m_postponeAutoReload || d->m_changedFiles.isEmpty()) return; if (QApplication::applicationState() != Qt::ApplicationActive) return; diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index b76e65d9627..b74734ac3c4 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -69,6 +69,8 @@ public: static void expectFileChange(const QString &fileName); static void unexpectFileChange(const QString &fileName); + static void setAutoReloadPostponed(bool enabled); + // recent files static void addToRecentFiles(const QString &fileName, Id editorId = Id()); Q_SLOT void clearRecentFiles(); diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index cf107697110..26db328083c 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -27,6 +27,7 @@ #include "vcsbaseplugin.h" #include "vcsoutputwindow.h" +#include #include #include @@ -56,6 +57,14 @@ VcsCommand::VcsCommand(const QString &workingDirectory, return proxy; }); + connect(this, &VcsCommand::started, this, [this] { + if (flags() & ExpectRepoChanges) + Core::DocumentManager::setAutoReloadPostponed(true); + }); + connect(this, &VcsCommand::finished, this, [this] { + if (flags() & ExpectRepoChanges) + Core::DocumentManager::setAutoReloadPostponed(false); + }); } const QProcessEnvironment VcsCommand::processEnvironment() const