mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
cleanup AnalThread
- removed MainWindow dependency - initalized members - added custom start function - handle thread running on destruction - hide QThread::start
This commit is contained in:
parent
a68d22f608
commit
df72be09a5
@ -1,18 +1,33 @@
|
||||
#include "analthread.h"
|
||||
#include "qrcore.h"
|
||||
#include <QDebug>
|
||||
#include "mainwindow.h"
|
||||
|
||||
AnalThread::AnalThread(MainWindow *w, QWidget *parent) :
|
||||
QThread(parent)
|
||||
AnalThread::AnalThread(QWidget *parent) :
|
||||
QThread(parent),
|
||||
core(nullptr),
|
||||
level(2)
|
||||
{
|
||||
// Radare core found in:
|
||||
this->w = w;
|
||||
//this->level = 2;
|
||||
}
|
||||
|
||||
AnalThread::~AnalThread()
|
||||
{
|
||||
if (isRunning()) {
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
void AnalThread::start(QRCore *core, int level)
|
||||
{
|
||||
this->core = core;
|
||||
this->level = level;
|
||||
|
||||
QThread::start();
|
||||
}
|
||||
|
||||
// run() will be called when a thread starts
|
||||
void AnalThread::run()
|
||||
{
|
||||
//qDebug() << "Anal level: " << this->level;
|
||||
this->w->core->analyze(this->level);
|
||||
core->analyze(this->level);
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
class MainWindow;
|
||||
class QRCore;
|
||||
|
||||
class AnalThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AnalThread(MainWindow *w, QWidget *parent = 0);
|
||||
explicit AnalThread(QWidget *parent = 0);
|
||||
~AnalThread();
|
||||
|
||||
void start(QRCore *core, int level);
|
||||
|
||||
protected:
|
||||
void run();
|
||||
int level;
|
||||
|
||||
using QThread::start;
|
||||
|
||||
private:
|
||||
|
||||
MainWindow *w;
|
||||
QRCore *core;
|
||||
int level;
|
||||
};
|
||||
|
||||
#endif // ANALTHREAD_H
|
||||
|
Loading…
Reference in New Issue
Block a user