forked from qt-creator/qt-creator
TaskTree: Introduce CallDoneIf enum
Get rid of CustomTask c'tor taking 3 handlers. If the done handler needs to be called only on success or an error, add explicit 3rd arg of CallDoneIf type. Task-number: QTCREATORBUG-29834 Change-Id: I10e55415587e6cac46620dd5177ad8269584583c Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -964,7 +964,7 @@ GroupItem GroupItem::withTimeout(const GroupItem &item, milliseconds timeout,
|
||||
Group {
|
||||
finishAllAndError,
|
||||
TimeoutTask([timeout](milliseconds &timeoutData) { timeoutData = timeout; },
|
||||
taskHandler)
|
||||
taskHandler, CallDoneIf::Success)
|
||||
},
|
||||
item
|
||||
};
|
||||
@@ -1483,9 +1483,16 @@ void TaskNode::stop()
|
||||
m_task.reset();
|
||||
}
|
||||
|
||||
static bool shouldCall(CallDoneIf callDoneIf, bool success)
|
||||
{
|
||||
if (success)
|
||||
return callDoneIf != CallDoneIf::Error;
|
||||
return callDoneIf != CallDoneIf::Success;
|
||||
}
|
||||
|
||||
void TaskNode::invokeDoneHandler(bool success)
|
||||
{
|
||||
if (m_taskHandler.m_doneHandler)
|
||||
if (m_taskHandler.m_doneHandler && shouldCall(m_taskHandler.m_callDoneIf, success))
|
||||
invokeHandler(parentContainer(), m_taskHandler.m_doneHandler, *m_task.get(), success);
|
||||
m_container.m_constData.m_taskTreePrivate->advanceProgress(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user