Add asserts to invalid Task states

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle
2026-01-21 17:10:14 +05:00
parent ef747055af
commit 9ac0314d7a

View File

@@ -98,6 +98,7 @@ void Task::start()
case State::Running: {
if (m_show_debug)
qCWarning(taskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
Q_ASSERT(!isRunning());
return;
}
}
@@ -112,6 +113,7 @@ void Task::emitFailed(QString reason)
// Don't fail twice.
if (!isRunning()) {
qCCritical(taskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
Q_ASSERT(!isRunning());
return;
}
m_state = State::Failed;
@@ -126,6 +128,7 @@ void Task::emitAborted()
// Don't abort twice.
if (!isRunning()) {
qCCritical(taskLogC) << "Task" << describe() << "aborted while not running!!!!";
Q_ASSERT(!isRunning());
return;
}
m_state = State::AbortedByUser;
@@ -141,6 +144,7 @@ void Task::emitSucceeded()
// Don't succeed twice.
if (!isRunning()) {
qCCritical(taskLogC) << "Task" << describe() << "succeeded while not running!!!!";
Q_ASSERT(!isRunning());
return;
}
m_state = State::Succeeded;