forked from qt-creator/qt-creator
VcsCommand: Fix unblocking GlobalFileChangeBlocker on abort
Change-Id: Ied60a0ecb291e50f4c48dc2e5df3371e4010932e Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -64,6 +64,7 @@ public:
|
|||||||
, m_environment(environment)
|
, m_environment(environment)
|
||||||
{
|
{
|
||||||
VcsBase::setProcessEnvironment(&m_environment);
|
VcsBase::setProcessEnvironment(&m_environment);
|
||||||
|
m_futureInterface.setProgressRange(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~VcsCommandPrivate() { delete m_progressParser; }
|
~VcsCommandPrivate() { delete m_progressParser; }
|
||||||
@@ -81,6 +82,8 @@ public:
|
|||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
int timeoutS() const;
|
int timeoutS() const;
|
||||||
|
|
||||||
|
void setup();
|
||||||
|
void cleanup();
|
||||||
void setupProcess(QtcProcess *process, const Job &job);
|
void setupProcess(QtcProcess *process, const Job &job);
|
||||||
void setupSynchronous(QtcProcess *process);
|
void setupSynchronous(QtcProcess *process);
|
||||||
bool isFullySynchronous() const;
|
bool isFullySynchronous() const;
|
||||||
@@ -134,6 +137,31 @@ int VcsCommandPrivate::timeoutS() const
|
|||||||
[](int sum, const Job &job) { return sum + job.timeoutS; });
|
[](int sum, const Job &job) { return sum + job.timeoutS; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsCommandPrivate::setup()
|
||||||
|
{
|
||||||
|
m_futureInterface.reportStarted();
|
||||||
|
if (m_flags & VcsCommand::ExpectRepoChanges) {
|
||||||
|
QMetaObject::invokeMethod(GlobalFileChangeBlocker::instance(), [] {
|
||||||
|
GlobalFileChangeBlocker::instance()->forceBlocked(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (m_progressParser)
|
||||||
|
m_progressParser->setFuture(&m_futureInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VcsCommandPrivate::cleanup()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_futureInterface.isRunning(), return);
|
||||||
|
m_futureInterface.reportFinished();
|
||||||
|
if (m_flags & VcsCommand::ExpectRepoChanges) {
|
||||||
|
QMetaObject::invokeMethod(GlobalFileChangeBlocker::instance(), [] {
|
||||||
|
GlobalFileChangeBlocker::instance()->forceBlocked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (m_progressParser)
|
||||||
|
m_progressParser->setFuture(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void VcsCommandPrivate::setupProcess(QtcProcess *process, const Job &job)
|
void VcsCommandPrivate::setupProcess(QtcProcess *process, const Job &job)
|
||||||
{
|
{
|
||||||
process->setExitCodeInterpreter(job.exitCodeInterpreter);
|
process->setExitCodeInterpreter(job.exitCodeInterpreter);
|
||||||
@@ -205,16 +233,7 @@ void VcsCommandPrivate::startAll()
|
|||||||
// Check that the binary path is not empty
|
// Check that the binary path is not empty
|
||||||
QTC_ASSERT(!m_jobs.isEmpty(), return);
|
QTC_ASSERT(!m_jobs.isEmpty(), return);
|
||||||
QTC_ASSERT(!m_process, return);
|
QTC_ASSERT(!m_process, return);
|
||||||
m_futureInterface.reportStarted();
|
setup();
|
||||||
if (m_flags & VcsCommand::ExpectRepoChanges) {
|
|
||||||
QMetaObject::invokeMethod(this, [] {
|
|
||||||
GlobalFileChangeBlocker::instance()->forceBlocked(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (m_progressParser)
|
|
||||||
m_progressParser->setFuture(&m_futureInterface);
|
|
||||||
else
|
|
||||||
m_futureInterface.setProgressRange(0, 1);
|
|
||||||
m_currentJob = 0;
|
m_currentJob = 0;
|
||||||
startNextJob();
|
startNextJob();
|
||||||
}
|
}
|
||||||
@@ -242,14 +261,8 @@ void VcsCommandPrivate::processDone()
|
|||||||
startNextJob();
|
startNextJob();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_flags & VcsCommand::ExpectRepoChanges) {
|
|
||||||
QMetaObject::invokeMethod(this, [] {
|
|
||||||
GlobalFileChangeBlocker::instance()->forceBlocked(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (m_aborted) {
|
if (m_aborted) {
|
||||||
m_futureInterface.reportCanceled();
|
m_futureInterface.reportCanceled();
|
||||||
m_futureInterface.reportFinished();
|
|
||||||
} else {
|
} else {
|
||||||
if (!m_progressiveOutput) {
|
if (!m_progressiveOutput) {
|
||||||
emit q->stdOutText(m_stdOut);
|
emit q->stdOutText(m_stdOut);
|
||||||
@@ -259,10 +272,8 @@ void VcsCommandPrivate::processDone()
|
|||||||
emit q->finished(success);
|
emit q->finished(success);
|
||||||
if (!success)
|
if (!success)
|
||||||
m_futureInterface.reportCanceled();
|
m_futureInterface.reportCanceled();
|
||||||
m_futureInterface.reportFinished();
|
|
||||||
}
|
}
|
||||||
if (m_progressParser)
|
cleanup();
|
||||||
m_progressParser->setFuture(nullptr);
|
|
||||||
// As it is used asynchronously, we need to delete ourselves
|
// As it is used asynchronously, we need to delete ourselves
|
||||||
q->deleteLater();
|
q->deleteLater();
|
||||||
}
|
}
|
||||||
@@ -304,7 +315,7 @@ VcsCommand::~VcsCommand()
|
|||||||
{
|
{
|
||||||
if (d->m_futureInterface.isRunning()) {
|
if (d->m_futureInterface.isRunning()) {
|
||||||
d->m_futureInterface.reportCanceled();
|
d->m_futureInterface.reportCanceled();
|
||||||
d->m_futureInterface.reportFinished();
|
d->cleanup();
|
||||||
}
|
}
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user