forked from qt-creator/qt-creator
ProcessProgress: Add setExpectedDuration() method
This is not the same as process timeout, so make these two settings orthogonal. Change-Id: I3fc774c183282fe770feb49258d77d0ce3637b38 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -147,7 +147,6 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
||||||
progress->setDisplayName(::CMakeProjectManager::Tr::tr("Configuring \"%1\"")
|
progress->setDisplayName(::CMakeProjectManager::Tr::tr("Configuring \"%1\"")
|
||||||
.arg(parameters.projectName));
|
.arg(parameters.projectName));
|
||||||
m_process->setTimeoutS(10); // for process progress timeout estimation
|
|
||||||
m_process->setCommand(commandLine);
|
m_process->setCommand(commandLine);
|
||||||
m_elapsed.start();
|
m_elapsed.start();
|
||||||
m_process->start();
|
m_process->start();
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class ProcessProgressPrivate : public QObject
|
class ProcessProgressPrivate : public QObject
|
||||||
@@ -32,6 +34,7 @@ public:
|
|||||||
QPointer<FutureProgress> m_futureProgress;
|
QPointer<FutureProgress> m_futureProgress;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
||||||
|
std::chrono::seconds m_expectedDuration = 2s;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, Process *process)
|
ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, Process *process)
|
||||||
@@ -98,7 +101,7 @@ ProcessProgress::ProcessProgress(Process *process)
|
|||||||
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), name, id);
|
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), name, id);
|
||||||
} else {
|
} else {
|
||||||
d->m_futureProgress = ProgressManager::addTimedTask(d->m_futureInterface, name, id,
|
d->m_futureProgress = ProgressManager::addTimedTask(d->m_futureInterface, name, id,
|
||||||
qMax(2, d->m_process->timeoutS() / 5));
|
d->m_expectedDuration.count());
|
||||||
}
|
}
|
||||||
d->m_futureProgress->setKeepOnFinish(d->m_keep);
|
d->m_futureProgress->setKeepOnFinish(d->m_keep);
|
||||||
});
|
});
|
||||||
@@ -145,4 +148,9 @@ void ProcessProgress::setProgressParser(const ProgressParser &parser)
|
|||||||
d.get(), &ProcessProgressPrivate::parseProgress);
|
d.get(), &ProcessProgressPrivate::parseProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessProgress::setExpectedDuration(std::chrono::seconds duration)
|
||||||
|
{
|
||||||
|
d->m_expectedDuration = qMin(1s, duration);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -26,6 +26,7 @@ public:
|
|||||||
void setDisplayName(const QString &name);
|
void setDisplayName(const QString &name);
|
||||||
void setKeepOnFinish(FutureProgress::KeepOnFinishType keepType);
|
void setKeepOnFinish(FutureProgress::KeepOnFinishType keepType);
|
||||||
void setProgressParser(const ProgressParser &parser);
|
void setProgressParser(const ProgressParser &parser);
|
||||||
|
void setExpectedDuration(std::chrono::seconds duration); // 2s by default
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<ProcessProgressPrivate> d;
|
std::unique_ptr<ProcessProgressPrivate> d;
|
||||||
|
@@ -377,7 +377,6 @@ void MesonProjectParser::setupProcess(const Command &command, const Environment
|
|||||||
MessageManager::writeFlashing(Tr::tr("Running %1 in %2.")
|
MessageManager::writeFlashing(Tr::tr("Running %1 in %2.")
|
||||||
.arg(command.toUserOutput(), command.workDir().toUserOutput()));
|
.arg(command.toUserOutput(), command.workDir().toUserOutput()));
|
||||||
m_process->setCommand(command.cmdLine());
|
m_process->setCommand(command.cmdLine());
|
||||||
m_process->setTimeoutS(10);
|
|
||||||
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
||||||
progress->setDisplayName(Tr::tr("Configuring \"%1\".").arg(projectName));
|
progress->setDisplayName(Tr::tr("Configuring \"%1\".").arg(projectName));
|
||||||
}
|
}
|
||||||
|
@@ -104,7 +104,6 @@ void VcsCommandPrivate::cleanup()
|
|||||||
|
|
||||||
void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
||||||
{
|
{
|
||||||
process->setTimeoutS(job.timeoutS);
|
|
||||||
if (!job.workingDirectory.isEmpty())
|
if (!job.workingDirectory.isEmpty())
|
||||||
process->setWorkingDirectory(job.workingDirectory);
|
process->setWorkingDirectory(job.workingDirectory);
|
||||||
if (!(m_flags & RunFlags::SuppressCommandLogging))
|
if (!(m_flags & RunFlags::SuppressCommandLogging))
|
||||||
@@ -125,6 +124,7 @@ void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
|||||||
|
|
||||||
ProcessProgress *progress = new ProcessProgress(process);
|
ProcessProgress *progress = new ProcessProgress(process);
|
||||||
progress->setDisplayName(m_displayName);
|
progress->setDisplayName(m_displayName);
|
||||||
|
progress->setExpectedDuration(std::chrono::seconds(qMin(1, job.timeoutS / 5)));
|
||||||
if (m_progressParser)
|
if (m_progressParser)
|
||||||
progress->setProgressParser(m_progressParser);
|
progress->setProgressParser(m_progressParser);
|
||||||
}
|
}
|
||||||
@@ -314,6 +314,7 @@ CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int time
|
|||||||
return {};
|
return {};
|
||||||
|
|
||||||
d->setupProcess(&process, {command, timeoutS, d->m_defaultWorkingDirectory, {}});
|
d->setupProcess(&process, {command, timeoutS, d->m_defaultWorkingDirectory, {}});
|
||||||
|
process.setTimeoutS(timeoutS);
|
||||||
|
|
||||||
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
||||||
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
||||||
|
Reference in New Issue
Block a user