forked from qt-creator/qt-creator
ShellCommand: De-virtualize runCommand()
Add virtual postRunCommand() method, called by the end of runCommand(). In this way the rest of the API of VcsCommand remains an implementation detail. Change-Id: Ia4149334bd39a1448266d2406e0987bee07a9c58 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -219,6 +219,11 @@ void ShellCommand::addTask(QFuture<void> &future)
|
|||||||
Q_UNUSED(future)
|
Q_UNUSED(future)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShellCommand::postRunCommand(const FilePath &workingDirectory)
|
||||||
|
{
|
||||||
|
Q_UNUSED(workingDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
int ShellCommand::timeoutS() const
|
int ShellCommand::timeoutS() const
|
||||||
{
|
{
|
||||||
return std::accumulate(d->m_jobs.cbegin(), d->m_jobs.cend(), 0,
|
return std::accumulate(d->m_jobs.cbegin(), d->m_jobs.cend(), 0,
|
||||||
@@ -318,6 +323,7 @@ void ShellCommand::runCommand(QtcProcess &proc,
|
|||||||
emit appendError(proc.exitMessage());
|
emit appendError(proc.exitMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
postRunCommand(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::runFullySynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
void ShellCommand::runFullySynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
||||||
|
|||||||
@@ -126,9 +126,8 @@ public:
|
|||||||
// This is called once per job in a thread.
|
// This is called once per job in a thread.
|
||||||
// When called from the UI thread it will execute fully synchronously, so no signals will
|
// When called from the UI thread it will execute fully synchronously, so no signals will
|
||||||
// be triggered!
|
// be triggered!
|
||||||
virtual void runCommand(QtcProcess &process,
|
void runCommand(QtcProcess &process, const CommandLine &command,
|
||||||
const CommandLine &command,
|
const FilePath &workingDirectory = {});
|
||||||
const FilePath &workingDirectory = {});
|
|
||||||
|
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
@@ -149,12 +148,13 @@ signals:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Environment environment() const;
|
virtual Environment environment() const;
|
||||||
virtual void addTask(QFuture<void> &future);
|
|
||||||
void setDisableUnixTerminal();
|
void setDisableUnixTerminal();
|
||||||
int timeoutS() const;
|
int timeoutS() const;
|
||||||
FilePath workDirectory(const FilePath &wd) const;
|
FilePath workDirectory(const FilePath &wd) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void addTask(QFuture<void> &future);
|
||||||
|
virtual void postRunCommand(const Utils::FilePath &workDirectory);
|
||||||
void run(QFutureInterface<void> &future);
|
void run(QFutureInterface<void> &future);
|
||||||
|
|
||||||
// Run without a event loop in fully blocking mode. No signals will be delivered.
|
// Run without a event loop in fully blocking mode. No signals will be delivered.
|
||||||
|
|||||||
@@ -82,14 +82,6 @@ Environment VcsCommand::environment() const
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommand::runCommand(QtcProcess &proc,
|
|
||||||
const CommandLine &command,
|
|
||||||
const FilePath &workingDirectory)
|
|
||||||
{
|
|
||||||
ShellCommand::runCommand(proc, command, workingDirectory);
|
|
||||||
emitRepositoryChanged(workingDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VcsCommand::addTask(QFuture<void> &future)
|
void VcsCommand::addTask(QFuture<void> &future)
|
||||||
{
|
{
|
||||||
const QString name = displayName();
|
const QString name = displayName();
|
||||||
@@ -114,13 +106,13 @@ void VcsCommand::addTask(QFuture<void> &future)
|
|||||||
Internal::VcsPlugin::addFuture(future);
|
Internal::VcsPlugin::addFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommand::emitRepositoryChanged(const FilePath &workingDirectory)
|
void VcsCommand::postRunCommand(const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
|
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
|
||||||
return;
|
return;
|
||||||
// TODO tell the document manager that the directory now received all expected changes
|
// TODO tell the document manager that the directory now received all expected changes
|
||||||
// Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
|
// Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
|
||||||
VcsManager::emitRepositoryChanged(workDirectory(workingDirectory));
|
VcsManager::emitRepositoryChanged(workingDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|||||||
@@ -48,16 +48,12 @@ public:
|
|||||||
|
|
||||||
VcsCommand(const Utils::FilePath &defaultWorkingDirectory, const Utils::Environment &environment);
|
VcsCommand(const Utils::FilePath &defaultWorkingDirectory, const Utils::Environment &environment);
|
||||||
|
|
||||||
void runCommand(Utils::QtcProcess &process,
|
|
||||||
const Utils::CommandLine &command,
|
|
||||||
const Utils::FilePath &workDirectory = {}) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Utils::Environment environment() const override;
|
Utils::Environment environment() const override;
|
||||||
void addTask(QFuture<void> &future) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitRepositoryChanged(const Utils::FilePath &workingDirectory);
|
void addTask(QFuture<void> &future) override;
|
||||||
|
void postRunCommand(const Utils::FilePath &workDirectory) override;
|
||||||
|
|
||||||
QPointer<Core::FutureProgress> m_progress;
|
QPointer<Core::FutureProgress> m_progress;
|
||||||
bool m_preventRepositoryChanged;
|
bool m_preventRepositoryChanged;
|
||||||
|
|||||||
Reference in New Issue
Block a user