cleanup AnalThread

- removed MainWindow dependency
- initalized members
- added custom start function
- handle thread running on destruction
- hide QThread::start
This commit is contained in:
ballessay 2017-04-01 00:43:12 +02:00
parent a68d22f608
commit df72be09a5
2 changed files with 33 additions and 12 deletions

View File

@ -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);
}

View File

@ -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