forked from qt-creator/qt-creator
TaskTree: Introduce DoneWith enum
This makes it possible to recognize the cancel state when the task was automatically stopped because of task's parent group workflow policy or when the user called TaskTree::stop(). This addresses the 2nd point in the master task below. Task-number: QTCREATORBUG-28741 Task-number: QTCREATORBUG-29834 Change-Id: I2798b9ec1d2f1d667aff51ee0271a5a15a525dc1 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -77,12 +77,12 @@ void tst_Tasking::validConstructs()
|
||||
{
|
||||
const Group task {
|
||||
parallel,
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, DoneWith) {}),
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
|
||||
TestTask([](TaskObject &) {}, [] {}),
|
||||
TestTask([](TaskObject &) {}, {}),
|
||||
TestTask([](TaskObject &) {}),
|
||||
TestTask({}, [](const TaskObject &, bool) {}),
|
||||
TestTask({}, [](const TaskObject &, DoneWith) {}),
|
||||
TestTask({}, [](const TaskObject &) {}),
|
||||
TestTask({}, [] {}),
|
||||
TestTask({}, {}),
|
||||
@@ -97,7 +97,7 @@ void tst_Tasking::validConstructs()
|
||||
parallel,
|
||||
Group {
|
||||
parallel,
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, DoneWith) {}),
|
||||
Group {
|
||||
parallel,
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
|
||||
@@ -108,7 +108,7 @@ void tst_Tasking::validConstructs()
|
||||
},
|
||||
Group {
|
||||
parallel,
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
|
||||
TestTask([](TaskObject &) {}, [](const TaskObject &, DoneWith) {}),
|
||||
onGroupDone([] {})
|
||||
}
|
||||
},
|
||||
@@ -120,7 +120,7 @@ void tst_Tasking::validConstructs()
|
||||
const auto setupHandler = [](TaskObject &) {};
|
||||
const auto finishHandler = [](const TaskObject &) {};
|
||||
const auto errorHandler = [](const TaskObject &) {};
|
||||
const auto doneHandler = [](const TaskObject &, bool) {};
|
||||
const auto doneHandler = [](const TaskObject &, DoneWith) {};
|
||||
|
||||
const Group task2 {
|
||||
parallel,
|
||||
@@ -230,10 +230,11 @@ void tst_Tasking::testTree_data()
|
||||
};
|
||||
};
|
||||
|
||||
const auto setupDone = [storage](int taskId, bool successTask = true) {
|
||||
return [storage, taskId, successTask](const TaskObject &, bool success) {
|
||||
storage->m_log.append({taskId, successTask && success ? Handler::Done : Handler::Error});
|
||||
return successTask && success;
|
||||
const auto setupDone = [storage](int taskId, bool success = true) {
|
||||
return [storage, taskId, success](const TaskObject &, DoneWith result) {
|
||||
const bool done = success && result != DoneWith::Cancel;
|
||||
storage->m_log.append({taskId, done ? Handler::Done : Handler::Error});
|
||||
return done;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ void Images::process()
|
||||
query.setNetworkAccessManager(&qnam);
|
||||
query.setRequest(QNetworkRequest(url));
|
||||
};
|
||||
const auto onDownloadDone = [this, storage, i](const NetworkQuery &query, bool success) {
|
||||
if (success)
|
||||
const auto onDownloadDone = [this, storage, i](const NetworkQuery &query, DoneWith result) {
|
||||
if (result == DoneWith::Success)
|
||||
*storage = query.reply()->readAll();
|
||||
else
|
||||
labels[i]->setText(tr("Download\nError.\nCode: %1.").arg(query.reply()->error()));
|
||||
@@ -89,8 +89,8 @@ void Images::process()
|
||||
const auto onScalingSetup = [storage](ConcurrentCall<QImage> &data) {
|
||||
data.setConcurrentCallData(&scale, *storage);
|
||||
};
|
||||
const auto onScalingDone = [this, i](const ConcurrentCall<QImage> &data, bool success) {
|
||||
if (success)
|
||||
const auto onScalingDone = [this, i](const ConcurrentCall<QImage> &data, DoneWith result) {
|
||||
if (result == DoneWith::Success)
|
||||
labels[i]->setPixmap(QPixmap::fromImage(data.result()));
|
||||
else
|
||||
labels[i]->setText(tr("Image\nData\nError."));
|
||||
|
||||
Reference in New Issue
Block a user