forked from qt-creator/qt-creator
ProjectExplorer: Use a lambda to parametrize promptToStop handling
Less coupling than using virtual functions for better re-use. Change-Id: Ibbab38175538f65c0f563129c87e01736ed220af Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -585,6 +585,7 @@ public:
|
||||
QPointer<TargetRunner> targetRunner; // Owned. QPointer as "extra safety" for now.
|
||||
QPointer<ToolRunner> toolRunner; // Owned. QPointer as "extra safety" for now.
|
||||
Utils::OutputFormatter *outputFormatter = nullptr;
|
||||
std::function<bool(bool*)> promptToStop;
|
||||
|
||||
// A handle to the actual application process.
|
||||
Utils::ProcessHandle applicationProcessHandle;
|
||||
@@ -882,10 +883,13 @@ void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
|
||||
bool RunControl::promptToStop(bool *optionalPrompt) const
|
||||
{
|
||||
QTC_ASSERT(isRunning(), return true);
|
||||
|
||||
if (optionalPrompt && !*optionalPrompt)
|
||||
return true;
|
||||
|
||||
// Overridden.
|
||||
if (d->promptToStop)
|
||||
return d->promptToStop(optionalPrompt);
|
||||
|
||||
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running.<center/>"
|
||||
"<center>Force it to quit?</center></body></html>").arg(displayName());
|
||||
return showPromptToStopDialog(tr("Application Still Running"), msg,
|
||||
@@ -893,6 +897,11 @@ bool RunControl::promptToStop(bool *optionalPrompt) const
|
||||
optionalPrompt);
|
||||
}
|
||||
|
||||
void RunControl::setPromptToStop(const std::function<bool (bool *)> &promptToStop)
|
||||
{
|
||||
d->promptToStop = promptToStop;
|
||||
}
|
||||
|
||||
bool RunControl::supportsReRunning() const
|
||||
{
|
||||
return d->supportsReRunning;
|
||||
|
||||
Reference in New Issue
Block a user