mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
Make AnalThread interruptable (Fix #264)
This commit is contained in:
parent
d3e48cdae1
commit
051b95c69d
@ -9,7 +9,8 @@ AnalThread::AnalThread(OptionsDialog *parent) :
|
|||||||
QThread(parent),
|
QThread(parent),
|
||||||
level(2),
|
level(2),
|
||||||
main(nullptr),
|
main(nullptr),
|
||||||
core(CutterCore::getInstance())
|
core(CutterCore::getInstance()),
|
||||||
|
interrupted(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +32,17 @@ void AnalThread::start(MainWindow *main, int level, QList<QString> advanced)
|
|||||||
QThread::start();
|
QThread::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnalThread::interruptAndWait()
|
||||||
|
{
|
||||||
|
interrupted = true;
|
||||||
|
|
||||||
|
while(isRunning())
|
||||||
|
{
|
||||||
|
r_cons_singleton()->breaked = true;
|
||||||
|
r_sys_usleep(10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// run() will be called when a thread starts
|
// run() will be called when a thread starts
|
||||||
void AnalThread::run()
|
void AnalThread::run()
|
||||||
{
|
{
|
||||||
@ -40,6 +52,8 @@ void AnalThread::run()
|
|||||||
ut64 loadaddr = 0LL;
|
ut64 loadaddr = 0LL;
|
||||||
ut64 mapaddr = 0LL;
|
ut64 mapaddr = 0LL;
|
||||||
|
|
||||||
|
interrupted = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Advanced Options
|
// Advanced Options
|
||||||
//
|
//
|
||||||
|
@ -15,6 +15,9 @@ public:
|
|||||||
~AnalThread();
|
~AnalThread();
|
||||||
|
|
||||||
void start(MainWindow *main, int level, QList<QString> advanced);
|
void start(MainWindow *main, int level, QList<QString> advanced);
|
||||||
|
void interruptAndWait();
|
||||||
|
|
||||||
|
bool isInterrupted() { return interrupted; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
@ -29,6 +32,8 @@ private:
|
|||||||
QList<QString> advanced;
|
QList<QString> advanced;
|
||||||
MainWindow *main;
|
MainWindow *main;
|
||||||
CutterCore *core;
|
CutterCore *core;
|
||||||
|
|
||||||
|
bool interrupted;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ANALTHREAD_H
|
#endif // ANALTHREAD_H
|
||||||
|
@ -262,6 +262,12 @@ void OptionsDialog::on_okButton_clicked()
|
|||||||
|
|
||||||
void OptionsDialog::anal_finished()
|
void OptionsDialog::anal_finished()
|
||||||
{
|
{
|
||||||
|
if (analThread.isInterrupted())
|
||||||
|
{
|
||||||
|
done(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui->statusLabel->setText(tr("Loading interface"));
|
ui->statusLabel->setText(tr("Loading interface"));
|
||||||
main->addOutput(tr(" > Analysis finished"));
|
main->addOutput(tr(" > Analysis finished"));
|
||||||
|
|
||||||
@ -269,6 +275,15 @@ void OptionsDialog::anal_finished()
|
|||||||
done(0);
|
done(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsDialog::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (analThread.isRunning())
|
||||||
|
{
|
||||||
|
analThread.interruptAndWait();
|
||||||
|
}
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
QString OptionsDialog::analysisDescription(int level)
|
QString OptionsDialog::analysisDescription(int level)
|
||||||
{
|
{
|
||||||
//TODO: replace this with meaningful descriptions
|
//TODO: replace this with meaningful descriptions
|
||||||
@ -362,7 +377,6 @@ void OptionsDialog::on_pdbSelectButton_clicked()
|
|||||||
|
|
||||||
void OptionsDialog::reject()
|
void OptionsDialog::reject()
|
||||||
{
|
{
|
||||||
delete main;
|
|
||||||
done(0);
|
done(0);
|
||||||
NewFileDialog *n = new NewFileDialog(nullptr);
|
NewFileDialog *n = new NewFileDialog(nullptr);
|
||||||
n->show();
|
n->show();
|
||||||
|
@ -40,6 +40,9 @@ private slots:
|
|||||||
|
|
||||||
void anal_finished();
|
void anal_finished();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnalThread analThread;
|
AnalThread analThread;
|
||||||
MainWindow *main;
|
MainWindow *main;
|
||||||
|
Loading…
Reference in New Issue
Block a user