forked from qt-creator/qt-creator
RunControl: Reuse TaskTreeRunner
Change-Id: Iad7731a1f124a08bcd81529d5fafd0960462de8d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <solutions/tasking/tasktree.h>
|
#include <solutions/tasking/tasktree.h>
|
||||||
|
#include <solutions/tasking/tasktreerunner.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -279,7 +281,7 @@ public:
|
|||||||
bool printEnvironment = false;
|
bool printEnvironment = false;
|
||||||
bool autoDelete = false;
|
bool autoDelete = false;
|
||||||
bool m_supportsReRunning = true;
|
bool m_supportsReRunning = true;
|
||||||
std::optional<Tasking::Group> m_runRecipe;
|
std::optional<Group> m_runRecipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RunControlPrivate : public QObject, public RunControlPrivateData
|
class RunControlPrivate : public QObject, public RunControlPrivateData
|
||||||
@@ -291,6 +293,9 @@ public:
|
|||||||
: q(parent), runMode(mode)
|
: q(parent), runMode(mode)
|
||||||
{
|
{
|
||||||
icon = Icons::RUN_SMALL_TOOLBAR;
|
icon = Icons::RUN_SMALL_TOOLBAR;
|
||||||
|
connect(&m_taskTreeRunner, &TaskTreeRunner::aboutToStart, q, &RunControl::started);
|
||||||
|
connect(&m_taskTreeRunner, &TaskTreeRunner::done,
|
||||||
|
this, &RunControlPrivate::checkAutoDeleteAndEmitStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RunControlPrivate() override
|
~RunControlPrivate() override
|
||||||
@@ -333,7 +338,7 @@ public:
|
|||||||
|
|
||||||
RunControl *q;
|
RunControl *q;
|
||||||
Id runMode;
|
Id runMode;
|
||||||
std::unique_ptr<Tasking::TaskTree> m_taskTree;
|
TaskTreeRunner m_taskTreeRunner;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
@@ -438,7 +443,7 @@ void RunControl::setAutoDeleteOnStop(bool autoDelete)
|
|||||||
d->autoDelete = autoDelete;
|
d->autoDelete = autoDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunControl::setRunRecipe(const Tasking::Group &group)
|
void RunControl::setRunRecipe(const Group &group)
|
||||||
{
|
{
|
||||||
d->m_runRecipe = group;
|
d->m_runRecipe = group;
|
||||||
}
|
}
|
||||||
@@ -466,7 +471,7 @@ void RunControl::initiateReStart()
|
|||||||
void RunControl::initiateStop()
|
void RunControl::initiateStop()
|
||||||
{
|
{
|
||||||
if (d->isUsingTaskTree()) {
|
if (d->isUsingTaskTree()) {
|
||||||
d->m_taskTree.reset();
|
d->m_taskTreeRunner.reset();
|
||||||
d->checkAutoDeleteAndEmitStopped();
|
d->checkAutoDeleteAndEmitStopped();
|
||||||
} else {
|
} else {
|
||||||
d->initiateStop();
|
d->initiateStop();
|
||||||
@@ -476,7 +481,7 @@ void RunControl::initiateStop()
|
|||||||
void RunControl::forceStop()
|
void RunControl::forceStop()
|
||||||
{
|
{
|
||||||
if (d->isUsingTaskTree()) {
|
if (d->isUsingTaskTree()) {
|
||||||
d->m_taskTree.reset();
|
d->m_taskTreeRunner.reset();
|
||||||
emit stopped();
|
emit stopped();
|
||||||
} else {
|
} else {
|
||||||
d->forceStop();
|
d->forceStop();
|
||||||
@@ -1072,15 +1077,7 @@ bool RunControlPrivate::supportsReRunning() const
|
|||||||
|
|
||||||
void RunControlPrivate::startTaskTree()
|
void RunControlPrivate::startTaskTree()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
m_taskTreeRunner.start(*m_runRecipe);
|
||||||
|
|
||||||
m_taskTree.reset(new TaskTree(*m_runRecipe));
|
|
||||||
connect(m_taskTree.get(), &TaskTree::started, q, &RunControl::started);
|
|
||||||
connect(m_taskTree.get(), &TaskTree::done, this, [this] {
|
|
||||||
m_taskTree.release()->deleteLater();
|
|
||||||
checkAutoDeleteAndEmitStopped();
|
|
||||||
});
|
|
||||||
m_taskTree->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunControlPrivate::checkAutoDeleteAndEmitStopped()
|
void RunControlPrivate::checkAutoDeleteAndEmitStopped()
|
||||||
@@ -1097,7 +1094,7 @@ void RunControlPrivate::checkAutoDeleteAndEmitStopped()
|
|||||||
bool RunControl::isRunning() const
|
bool RunControl::isRunning() const
|
||||||
{
|
{
|
||||||
if (d->isUsingTaskTree())
|
if (d->isUsingTaskTree())
|
||||||
return d->m_taskTree.get();
|
return d->m_taskTreeRunner.isRunning();
|
||||||
return d->state == RunControlState::Running;
|
return d->state == RunControlState::Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1111,7 +1108,7 @@ bool RunControl::isStarting() const
|
|||||||
bool RunControl::isStopped() const
|
bool RunControl::isStopped() const
|
||||||
{
|
{
|
||||||
if (d->isUsingTaskTree())
|
if (d->isUsingTaskTree())
|
||||||
return !d->m_taskTree.get();
|
return !d->m_taskTreeRunner.isRunning();
|
||||||
return d->state == RunControlState::Stopped;
|
return d->state == RunControlState::Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user