ProjectExplorer: Unify RunControl setup/teardown

Provide protected methods in RunControl to handle the notification
of when the RunControl starts and stops. Use these helpers to
move the isRunning() method into the RunConfiguration itself instead
of reimplementing it everywhere.

Change-Id: Ia8de42f7a6a14a049870d4e7fcb9af6756c2caa4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-02-27 17:25:58 +01:00
parent 329db5f4cc
commit e07c6383d7
22 changed files with 78 additions and 156 deletions

View File

@@ -37,6 +37,7 @@
#include <utils/algorithm.h>
#include <utils/outputformatter.h>
#include <utils/checkablemessagebox.h>
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
@@ -534,10 +535,12 @@ public:
// A handle to the actual application process.
Utils::ProcessHandle applicationProcessHandle;
bool isRunning = false;
#ifdef Q_OS_OSX
//these two are used to bring apps in the foreground on Mac
qint64 internalPid;
int foregroundCount;
qint64 internalPid;
#endif
};
@@ -662,7 +665,7 @@ void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
{
if (d->applicationProcessHandle != handle) {
d->applicationProcessHandle = handle;
emit applicationProcessHandleChanged();
emit applicationProcessHandleChanged(QPrivateSignal());
}
}
@@ -685,6 +688,11 @@ bool RunControl::promptToStop(bool *optionalPrompt) const
optionalPrompt);
}
bool RunControl::isRunning() const
{
return d->isRunning;
}
/*!
Prompts to terminate the application with the \gui {Do not ask again}
checkbox.
@@ -732,6 +740,20 @@ void RunControl::bringApplicationToForeground(qint64 pid)
#endif
}
void RunControl::reportApplicationStart()
{
d->isRunning = true;
emit started(QPrivateSignal());
}
void RunControl::reportApplicationStop()
{
d->isRunning = false;
QTC_CHECK(d->applicationProcessHandle.isValid());
setApplicationProcessHandle(Utils::ProcessHandle());
emit finished(QPrivateSignal());
}
void RunControl::bringApplicationToForegroundInternal()
{
#ifdef Q_OS_OSX