#include "R2Task.h" R2Task::R2Task(const QString &cmd) { task = r_core_task_new(Core()->core(), true, cmd.toLocal8Bit().constData(), static_cast(&R2Task::taskFinishedCallback), this); } R2Task::~R2Task() { // Don't delete current task as it might be still running // Just delete any task that is done. r_core_task_del_all_done(Core()->core()); } void R2Task::taskFinishedCallback(void *user, char *) { reinterpret_cast(user)->taskFinished(); } void R2Task::taskFinished() { emit finished(); } void R2Task::startTask() { r_core_task_enqueue(Core()->core(), task); } void R2Task::breakTask() { r_core_task_break(Core()->core(), task->id); } void R2Task::joinTask() { r_core_task_join(Core()->core(), nullptr, task->id); } QString R2Task::getResult() { return QString::fromUtf8(task->res); } const char *R2Task::getResultRaw() { return task->res; }