Update Rizin with RizinTask (#2517)

This commit is contained in:
Florian Märkl 2020-12-16 10:51:53 +01:00 committed by GitHub
parent cd10751327
commit 58745547a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 144 additions and 136 deletions

2
rizin

@ -1 +1 @@
Subproject commit 2ae7f4df15228a83d65f1a509675ee48b6237694 Subproject commit 8af2c6aa9bba10a310a77ecef82d44ee80aeb470

View File

@ -383,8 +383,8 @@ SOURCES += \
dialogs/MapFileDialog.cpp \ dialogs/MapFileDialog.cpp \
common/CommandTask.cpp \ common/CommandTask.cpp \
common/ProgressIndicator.cpp \ common/ProgressIndicator.cpp \
common/R2Task.cpp \ common/RizinTask.cpp \
dialogs/R2TaskDialog.cpp \ dialogs/RizinTaskDialog.cpp \
widgets/DebugActions.cpp \ widgets/DebugActions.cpp \
widgets/MemoryMapWidget.cpp \ widgets/MemoryMapWidget.cpp \
dialogs/preferences/DebugOptionsWidget.cpp \ dialogs/preferences/DebugOptionsWidget.cpp \
@ -536,8 +536,8 @@ HEADERS += \
common/CommandTask.h \ common/CommandTask.h \
common/ProgressIndicator.h \ common/ProgressIndicator.h \
plugins/CutterPlugin.h \ plugins/CutterPlugin.h \
common/R2Task.h \ common/RizinTask.h \
dialogs/R2TaskDialog.h \ dialogs/RizinTaskDialog.h \
widgets/DebugActions.h \ widgets/DebugActions.h \
widgets/MemoryMapWidget.h \ widgets/MemoryMapWidget.h \
dialogs/preferences/DebugOptionsWidget.h \ dialogs/preferences/DebugOptionsWidget.h \
@ -643,7 +643,7 @@ FORMS += \
dialogs/VersionInfoDialog.ui \ dialogs/VersionInfoDialog.ui \
widgets/ZignaturesWidget.ui \ widgets/ZignaturesWidget.ui \
dialogs/AsyncTaskDialog.ui \ dialogs/AsyncTaskDialog.ui \
dialogs/R2TaskDialog.ui \ dialogs/RizinTaskDialog.ui \
widgets/StackWidget.ui \ widgets/StackWidget.ui \
widgets/RegistersWidget.ui \ widgets/RegistersWidget.ui \
widgets/ThreadsWidget.ui \ widgets/ThreadsWidget.ui \

View File

@ -33,8 +33,8 @@ void R2DecDecompiler::decompileAt(RVA addr)
if (task) { if (task) {
return; return;
} }
task = new R2Task("pddj @ " + QString::number(addr)); task = new RizinTask("pddj @ " + QString::number(addr));
connect(task, &R2Task::finished, this, [this]() { connect(task, &RizinTask::finished, this, [this]() {
QJsonObject json = task->getResultJson().object(); QJsonObject json = task->getResultJson().object();
delete task; delete task;
task = nullptr; task = nullptr;

View File

@ -2,7 +2,7 @@
#define DECOMPILER_H #define DECOMPILER_H
#include "CutterCommon.h" #include "CutterCommon.h"
#include "R2Task.h" #include "RizinTask.h"
#include <rz_util/rz_annotated_code.h> #include <rz_util/rz_annotated_code.h>
#include <QString> #include <QString>
@ -42,7 +42,7 @@ class R2DecDecompiler: public Decompiler
Q_OBJECT Q_OBJECT
private: private:
R2Task *task; RizinTask *task;
public: public:
explicit R2DecDecompiler(QObject *parent = nullptr); explicit R2DecDecompiler(QObject *parent = nullptr);

View File

@ -1,58 +0,0 @@
#include "R2Task.h"
R2Task::R2Task(const QString &cmd, bool transient)
{
task = rz_core_task_new(Core()->core(),
true,
cmd.toLocal8Bit().constData(),
static_cast<RzCoreTaskCallback>(&R2Task::taskFinishedCallback),
this);
task->transient = transient;
rz_core_task_incref(task);
}
R2Task::~R2Task()
{
rz_core_task_decref(task);
}
void R2Task::taskFinishedCallback(void *user, char *)
{
reinterpret_cast<R2Task *>(user)->taskFinished();
}
void R2Task::taskFinished()
{
emit finished();
}
void R2Task::startTask()
{
rz_core_task_enqueue(&Core()->core_->tasks, task);
}
void R2Task::breakTask()
{
rz_core_task_break(&Core()->core_->tasks, task->id);
}
void R2Task::joinTask()
{
rz_core_task_join(&Core()->core_->tasks, nullptr, task->id);
}
QString R2Task::getResult()
{
return QString::fromUtf8(task->res);
}
QJsonDocument R2Task::getResultJson()
{
return Core()->parseJson(task->res, task->cmd);
}
const char *R2Task::getResultRaw()
{
return task->res;
}

66
src/common/RizinTask.cpp Normal file
View File

@ -0,0 +1,66 @@
#include "RizinTask.h"
#include <rz_core.h>
RizinTask::RizinTask(const QString &cmd, bool transient)
{
task = rz_core_cmd_task_new(Core()->core(),
cmd.toLocal8Bit().constData(),
static_cast<RzCoreCmdTaskFinished>(&RizinTask::taskFinishedCallback),
this);
task->transient = transient;
rz_core_task_incref(task);
}
RizinTask::~RizinTask()
{
rz_core_task_decref(task);
}
void RizinTask::taskFinishedCallback(const char *, void *user)
{
reinterpret_cast<RizinTask *>(user)->taskFinished();
}
void RizinTask::taskFinished()
{
emit finished();
}
void RizinTask::startTask()
{
rz_core_task_enqueue(&Core()->core_->tasks, task);
}
void RizinTask::breakTask()
{
rz_core_task_break(&Core()->core_->tasks, task->id);
}
void RizinTask::joinTask()
{
rz_core_task_join(&Core()->core_->tasks, nullptr, task->id);
}
QString RizinTask::getResult()
{
const char *res = rz_core_cmd_task_get_result(task);
if(!res) {
return nullptr;
}
return QString::fromUtf8(res);
}
QJsonDocument RizinTask::getResultJson()
{
const char *res = rz_core_cmd_task_get_result(task);
if(!res) {
return QJsonDocument();
}
return Core()->parseJson(res, nullptr);
}
const char *RizinTask::getResultRaw()
{
return rz_core_cmd_task_get_result(task);
}

View File

@ -4,21 +4,21 @@
#include "core/Cutter.h" #include "core/Cutter.h"
class R2Task: public QObject class RizinTask: public QObject
{ {
Q_OBJECT Q_OBJECT
private: private:
RzCoreTask *task; RzCoreTask *task;
static void taskFinishedCallback(void *user, char *); static void taskFinishedCallback(const char *, void *user);
void taskFinished(); void taskFinished();
public: public:
using Ptr = QSharedPointer<R2Task>; using Ptr = QSharedPointer<RizinTask>;
explicit R2Task(const QString &cmd, bool transient = true); explicit RizinTask(const QString &cmd, bool transient = true);
~R2Task(); ~RizinTask();
void startTask(); void startTask();
void breakTask(); void breakTask();

View File

@ -14,7 +14,7 @@
#include "common/BasicInstructionHighlighter.h" #include "common/BasicInstructionHighlighter.h"
#include "common/Configuration.h" #include "common/Configuration.h"
#include "common/AsyncTask.h" #include "common/AsyncTask.h"
#include "common/R2Task.h" #include "common/RizinTask.h"
#include "common/Json.h" #include "common/Json.h"
#include "core/Cutter.h" #include "core/Cutter.h"
#include "Decompiler.h" #include "Decompiler.h"
@ -394,7 +394,7 @@ bool CutterCore::isDebugTaskInProgress()
return false; return false;
} }
bool CutterCore::asyncCmdEsil(const char *command, QSharedPointer<R2Task> &task) bool CutterCore::asyncCmdEsil(const char *command, QSharedPointer<RizinTask> &task)
{ {
asyncCmd(command, task); asyncCmd(command, task);
@ -402,7 +402,7 @@ bool CutterCore::asyncCmdEsil(const char *command, QSharedPointer<R2Task> &task)
return false; return false;
} }
connect(task.data(), &R2Task::finished, task.data(), [this, task] () { connect(task.data(), &RizinTask::finished, task.data(), [this, task] () {
QString res = task.data()->getResult(); QString res = task.data()->getResult();
if (res.contains(QStringLiteral("[ESIL] Stopped execution in an invalid instruction"))) { if (res.contains(QStringLiteral("[ESIL] Stopped execution in an invalid instruction"))) {
@ -413,7 +413,7 @@ bool CutterCore::asyncCmdEsil(const char *command, QSharedPointer<R2Task> &task)
return true; return true;
} }
bool CutterCore::asyncCmd(const char *str, QSharedPointer<R2Task> &task) bool CutterCore::asyncCmd(const char *str, QSharedPointer<RizinTask> &task)
{ {
if (!task.isNull()) { if (!task.isNull()) {
return false; return false;
@ -423,8 +423,8 @@ bool CutterCore::asyncCmd(const char *str, QSharedPointer<R2Task> &task)
RVA offset = core->offset; RVA offset = core->offset;
task = QSharedPointer<R2Task>(new R2Task(str, true)); task = QSharedPointer<RizinTask>(new RizinTask(str, true));
connect(task.data(), &R2Task::finished, task.data(), [this, offset, task] () { connect(task.data(), &RizinTask::finished, task.data(), [this, offset, task] () {
CORE_LOCK(); CORE_LOCK();
if (offset != core->offset) { if (offset != core->offset) {
@ -494,7 +494,7 @@ QJsonDocument CutterCore::cmdjAt(const char *str, RVA address)
QString CutterCore::cmdTask(const QString &str) QString CutterCore::cmdTask(const QString &str)
{ {
R2Task task(str); RizinTask task(str);
task.startTask(); task.startTask();
task.joinTask(); task.joinTask();
return task.getResult(); return task.getResult();
@ -502,7 +502,7 @@ QString CutterCore::cmdTask(const QString &str)
QJsonDocument CutterCore::cmdjTask(const QString &str) QJsonDocument CutterCore::cmdjTask(const QString &str)
{ {
R2Task task(str); RizinTask task(str);
task.startTask(); task.startTask();
task.joinTask(); task.joinTask();
return parseJson(task.getResultRaw(), str); return parseJson(task.getResultRaw(), str);
@ -1602,7 +1602,7 @@ void CutterCore::setCurrentDebugThread(int tid)
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
emit registersChanged(); emit registersChanged();
emit refreshCodeViews(); emit refreshCodeViews();
@ -1622,7 +1622,7 @@ void CutterCore::setCurrentDebugProcess(int pid)
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
emit registersChanged(); emit registersChanged();
emit refreshCodeViews(); emit refreshCodeViews();
@ -1649,7 +1649,7 @@ void CutterCore::startDebug()
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
if (debugTaskDialog) { if (debugTaskDialog) {
delete debugTaskDialog; delete debugTaskDialog;
} }
@ -1668,7 +1668,7 @@ void CutterCore::startDebug()
emit debugTaskStateChanged(); emit debugTaskStateChanged();
}); });
debugTaskDialog = new R2TaskDialog(debugTask); debugTaskDialog = new RizinTaskDialog(debugTask);
debugTaskDialog->setBreakOnClose(true); debugTaskDialog->setBreakOnClose(true);
debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose); debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose);
debugTaskDialog->setDesc(tr("Starting native debug...")); debugTaskDialog->setDesc(tr("Starting native debug..."));
@ -1688,7 +1688,7 @@ void CutterCore::startEmulation()
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
if (debugTaskDialog) { if (debugTaskDialog) {
delete debugTaskDialog; delete debugTaskDialog;
} }
@ -1711,7 +1711,7 @@ void CutterCore::startEmulation()
emit debugTaskStateChanged(); emit debugTaskStateChanged();
}); });
debugTaskDialog = new R2TaskDialog(debugTask); debugTaskDialog = new RizinTaskDialog(debugTask);
debugTaskDialog->setBreakOnClose(true); debugTaskDialog->setBreakOnClose(true);
debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose); debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose);
debugTaskDialog->setDesc(tr("Starting emulation...")); debugTaskDialog->setDesc(tr("Starting emulation..."));
@ -1730,7 +1730,7 @@ void CutterCore::attachRemote(const QString &uri)
asyncCmd("e cfg.debug = true; oodf " + uri, debugTask); asyncCmd("e cfg.debug = true; oodf " + uri, debugTask);
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this, uri] () { connect(debugTask.data(), &RizinTask::finished, this, [this, uri] () {
if (debugTaskDialog) { if (debugTaskDialog) {
delete debugTaskDialog; delete debugTaskDialog;
} }
@ -1767,7 +1767,7 @@ void CutterCore::attachRemote(const QString &uri)
emit debugTaskStateChanged(); emit debugTaskStateChanged();
}); });
debugTaskDialog = new R2TaskDialog(debugTask); debugTaskDialog = new RizinTaskDialog(debugTask);
debugTaskDialog->setBreakOnClose(true); debugTaskDialog->setBreakOnClose(true);
debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose); debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose);
debugTaskDialog->setDesc(tr("Connecting to: ") + uri); debugTaskDialog->setDesc(tr("Connecting to: ") + uri);
@ -1786,7 +1786,7 @@ void CutterCore::attachDebug(int pid)
asyncCmd("e cfg.debug = true; oodf dbg://" + QString::number(pid), debugTask); asyncCmd("e cfg.debug = true; oodf dbg://" + QString::number(pid), debugTask);
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this, pid] () { connect(debugTask.data(), &RizinTask::finished, this, [this, pid] () {
if (debugTaskDialog) { if (debugTaskDialog) {
delete debugTaskDialog; delete debugTaskDialog;
} }
@ -1806,7 +1806,7 @@ void CutterCore::attachDebug(int pid)
emit debugTaskStateChanged(); emit debugTaskStateChanged();
}); });
debugTaskDialog = new R2TaskDialog(debugTask); debugTaskDialog = new RizinTaskDialog(debugTask);
debugTaskDialog->setBreakOnClose(true); debugTaskDialog->setBreakOnClose(true);
debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose); debugTaskDialog->setAttribute(Qt::WA_DeleteOnClose);
debugTaskDialog->setDesc(tr("Attaching to process (") + QString::number(pid) + ")..."); debugTaskDialog->setDesc(tr("Attaching to process (") + QString::number(pid) + ")...");
@ -1890,7 +1890,7 @@ void CutterCore::continueDebug()
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit registersChanged(); emit registersChanged();
@ -1918,7 +1918,7 @@ void CutterCore::continueUntilDebug(QString offset)
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit registersChanged(); emit registersChanged();
@ -1947,7 +1947,7 @@ void CutterCore::continueUntilCall()
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit debugTaskStateChanged(); emit debugTaskStateChanged();
@ -1973,7 +1973,7 @@ void CutterCore::continueUntilSyscall()
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit debugTaskStateChanged(); emit debugTaskStateChanged();
@ -1999,7 +1999,7 @@ void CutterCore::stepDebug()
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit debugTaskStateChanged(); emit debugTaskStateChanged();
@ -2025,7 +2025,7 @@ void CutterCore::stepOverDebug()
} }
emit debugTaskStateChanged(); emit debugTaskStateChanged();
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit debugTaskStateChanged(); emit debugTaskStateChanged();
@ -2045,7 +2045,7 @@ void CutterCore::stepOutDebug()
return; return;
} }
connect(debugTask.data(), &R2Task::finished, this, [this] () { connect(debugTask.data(), &RizinTask::finished, this, [this] () {
debugTask.clear(); debugTask.clear();
syncAndSeekProgramCounter(); syncAndSeekProgramCounter();
emit debugTaskStateChanged(); emit debugTaskStateChanged();

View File

@ -20,13 +20,13 @@ class AsyncTaskManager;
class BasicInstructionHighlighter; class BasicInstructionHighlighter;
class CutterCore; class CutterCore;
class Decompiler; class Decompiler;
class R2Task; class RizinTask;
class R2TaskDialog; class RizinTaskDialog;
#include "common/BasicBlockHighlighter.h" #include "common/BasicBlockHighlighter.h"
#include "common/R2Task.h" #include "common/RizinTask.h"
#include "common/Helpers.h" #include "common/Helpers.h"
#include "dialogs/R2TaskDialog.h" #include "dialogs/RizinTaskDialog.h"
#include <rz_project.h> #include <rz_project.h>
@ -39,7 +39,7 @@ class CUTTER_EXPORT CutterCore: public QObject
Q_OBJECT Q_OBJECT
friend class RzCoreLocked; friend class RzCoreLocked;
friend class R2Task; friend class RizinTask;
public: public:
explicit CutterCore(QObject *parent = nullptr); explicit CutterCore(QObject *parent = nullptr);
@ -69,14 +69,14 @@ public:
* @brief send a command to Rizin asynchronously * @brief send a command to Rizin asynchronously
* @param str the command you want to execute * @param str the command you want to execute
* @param task a shared pointer that will be returned with the R2 command task * @param task a shared pointer that will be returned with the R2 command task
* @note connect to the &R2Task::finished signal to add your own logic once * @note connect to the &RizinTask::finished signal to add your own logic once
* the command is finished. Use task->getResult()/getResultJson() for the * the command is finished. Use task->getResult()/getResultJson() for the
* return value. * return value.
* Once you have setup connections you can start the task with task->startTask() * Once you have setup connections you can start the task with task->startTask()
* If you want to seek to an address, you should use CutterCore::seek. * If you want to seek to an address, you should use CutterCore::seek.
*/ */
bool asyncCmd(const char *str, QSharedPointer<R2Task> &task); bool asyncCmd(const char *str, QSharedPointer<RizinTask> &task);
bool asyncCmd(const QString &str, QSharedPointer<R2Task> &task) { return asyncCmd(str.toUtf8().constData(), task); } bool asyncCmd(const QString &str, QSharedPointer<RizinTask> &task) { return asyncCmd(str.toUtf8().constData(), task); }
/** /**
* @brief Execute a Rizin command \a cmd. By nature, the API * @brief Execute a Rizin command \a cmd. By nature, the API
@ -126,14 +126,14 @@ public:
* @brief send a command to Rizin and check for ESIL errors * @brief send a command to Rizin and check for ESIL errors
* @param command the command you want to execute * @param command the command you want to execute
* @param task a shared pointer that will be returned with the R2 command task * @param task a shared pointer that will be returned with the R2 command task
* @note connect to the &R2Task::finished signal to add your own logic once * @note connect to the &RizinTask::finished signal to add your own logic once
* the command is finished. Use task->getResult()/getResultJson() for the * the command is finished. Use task->getResult()/getResultJson() for the
* return value. * return value.
* Once you have setup connections you can start the task with task->startTask() * Once you have setup connections you can start the task with task->startTask()
* If you want to seek to an address, you should use CutterCore::seek. * If you want to seek to an address, you should use CutterCore::seek.
*/ */
bool asyncCmdEsil(const char *command, QSharedPointer<R2Task> &task); bool asyncCmdEsil(const char *command, QSharedPointer<RizinTask> &task);
bool asyncCmdEsil(const QString &command, QSharedPointer<R2Task> &task) { return asyncCmdEsil(command.toUtf8().constData(), task); } bool asyncCmdEsil(const QString &command, QSharedPointer<RizinTask> &task) { return asyncCmdEsil(command.toUtf8().constData(), task); }
QString getVersionInformation(); QString getVersionInformation();
QJsonDocument parseJson(const char *res, const char *cmd = nullptr); QJsonDocument parseJson(const char *res, const char *cmd = nullptr);
@ -725,8 +725,8 @@ private:
bool iocache = false; bool iocache = false;
BasicInstructionHighlighter biHighlighter; BasicInstructionHighlighter biHighlighter;
QSharedPointer<R2Task> debugTask; QSharedPointer<RizinTask> debugTask;
R2TaskDialog *debugTaskDialog; RizinTaskDialog *debugTaskDialog;
QVector<QString> getCutterRCFilePaths() const; QVector<QString> getCutterRCFilePaths() const;
}; };

View File

@ -1,22 +1,22 @@
#include "R2TaskDialog.h" #include "RizinTaskDialog.h"
#include "common/R2Task.h" #include "common/RizinTask.h"
#include <QCloseEvent> #include <QCloseEvent>
#include "ui_R2TaskDialog.h" #include "ui_RizinTaskDialog.h"
R2TaskDialog::R2TaskDialog(R2Task::Ptr task, QWidget *parent) RizinTaskDialog::RizinTaskDialog(RizinTask::Ptr task, QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::R2TaskDialog), ui(new Ui::RizinTaskDialog),
task(task) task(task)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(task.data(), &R2Task::finished, this, [this]() { connect(task.data(), &RizinTask::finished, this, [this]() {
close(); close();
}); });
connect(&timer, &QTimer::timeout, this, &R2TaskDialog::updateProgressTimer); connect(&timer, &QTimer::timeout, this, &RizinTaskDialog::updateProgressTimer);
timer.setInterval(1000); timer.setInterval(1000);
timer.setSingleShot(false); timer.setSingleShot(false);
timer.start(); timer.start();
@ -25,11 +25,11 @@ R2TaskDialog::R2TaskDialog(R2Task::Ptr task, QWidget *parent)
updateProgressTimer(); updateProgressTimer();
} }
R2TaskDialog::~R2TaskDialog() RizinTaskDialog::~RizinTaskDialog()
{ {
} }
void R2TaskDialog::updateProgressTimer() void RizinTaskDialog::updateProgressTimer()
{ {
int secondsElapsed = elapsedTimer.elapsed() / 1000; int secondsElapsed = elapsedTimer.elapsed() / 1000;
int minutesElapsed = secondsElapsed / 60; int minutesElapsed = secondsElapsed / 60;
@ -48,12 +48,12 @@ void R2TaskDialog::updateProgressTimer()
ui->timeLabel->setText(label); ui->timeLabel->setText(label);
} }
void R2TaskDialog::setDesc(const QString &label) void RizinTaskDialog::setDesc(const QString &label)
{ {
ui->descLabel->setText(label); ui->descLabel->setText(label);
} }
void R2TaskDialog::closeEvent(QCloseEvent *event) void RizinTaskDialog::closeEvent(QCloseEvent *event)
{ {
if (breakOnClose) { if (breakOnClose) {
task->breakTask(); task->breakTask();
@ -64,7 +64,7 @@ void R2TaskDialog::closeEvent(QCloseEvent *event)
} }
} }
void R2TaskDialog::reject() void RizinTaskDialog::reject()
{ {
task->breakTask(); task->breakTask();
setDesc("Attempting to stop the task..."); setDesc("Attempting to stop the task...");

View File

@ -7,22 +7,22 @@
#include <QTimer> #include <QTimer>
#include <QElapsedTimer> #include <QElapsedTimer>
#include "common/R2Task.h" #include "common/RizinTask.h"
#include "core/CutterCommon.h" #include "core/CutterCommon.h"
class R2Task; class RizinTask;
namespace Ui { namespace Ui {
class R2TaskDialog; class RizinTaskDialog;
} }
class CUTTER_EXPORT R2TaskDialog : public QDialog class CUTTER_EXPORT RizinTaskDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
using Ptr = QSharedPointer<R2Task>; using Ptr = QSharedPointer<RizinTask>;
R2TaskDialog(Ptr task, QWidget *parent = nullptr); RizinTaskDialog(Ptr task, QWidget *parent = nullptr);
~R2TaskDialog(); ~RizinTaskDialog();
void setBreakOnClose(bool v) { breakOnClose = v; } void setBreakOnClose(bool v) { breakOnClose = v; }
bool getBreakOnClose() { return breakOnClose; } bool getBreakOnClose() { return breakOnClose; }
@ -38,8 +38,8 @@ protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
private: private:
std::unique_ptr<Ui::R2TaskDialog> ui; std::unique_ptr<Ui::RizinTaskDialog> ui;
QSharedPointer<R2Task> task; QSharedPointer<RizinTask> task;
QTimer timer; QTimer timer;
QElapsedTimer elapsedTimer; QElapsedTimer elapsedTimer;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>R2TaskDialog</class> <class>RizinTaskDialog</class>
<widget class="QDialog" name="R2TaskDialog"> <widget class="QDialog" name="RizinTaskDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -58,7 +58,7 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>R2TaskDialog</receiver> <receiver>RizinTaskDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@ -74,7 +74,7 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>R2TaskDialog</receiver> <receiver>RizinTaskDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">