mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
OptionsDialog: fixed memleak
Hold thread as member so the lifetime of it is handled by the dialog. Another option would be a std::unique_ptr.
This commit is contained in:
parent
df72be09a5
commit
c42faba81c
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
OptionsDialog::OptionsDialog(QWidget *parent):
|
OptionsDialog::OptionsDialog(QWidget *parent):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::OptionsDialog)
|
ui(new Ui::OptionsDialog),
|
||||||
|
analThread(this)
|
||||||
{
|
{
|
||||||
this->core = new QRCore();
|
this->core = new QRCore();
|
||||||
this->anal_level = 0;
|
this->anal_level = 0;
|
||||||
@ -39,6 +40,8 @@ OptionsDialog::OptionsDialog(QWidget *parent):
|
|||||||
|
|
||||||
// Add this so the dialog resizes when widgets are shown/hidden
|
// Add this so the dialog resizes when widgets are shown/hidden
|
||||||
//this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
//this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
|
||||||
|
connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsDialog::~OptionsDialog()
|
OptionsDialog::~OptionsDialog()
|
||||||
@ -169,18 +172,14 @@ void OptionsDialog::on_okButton_clicked()
|
|||||||
ui->statusLabel->setText("Analysis in progress");
|
ui->statusLabel->setText("Analysis in progress");
|
||||||
|
|
||||||
// Threads stuff
|
// Threads stuff
|
||||||
// create an instance of MyThread
|
|
||||||
this->analThread = new AnalThread(w);
|
|
||||||
|
|
||||||
// connect signal/slot
|
// connect signal/slot
|
||||||
connect(analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
|
|
||||||
//analThread->level = anal_level;
|
int level = 0;
|
||||||
if (anal_level == true) {
|
if (anal_level == true) {
|
||||||
analThread->level = ui->analSlider->value();
|
level = ui->analSlider->value();
|
||||||
} else {
|
|
||||||
analThread->level = 0;
|
|
||||||
}
|
}
|
||||||
analThread->start();
|
|
||||||
|
analThread.start(core, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::anal_finished()
|
void OptionsDialog::anal_finished()
|
||||||
|
@ -43,7 +43,7 @@ private:
|
|||||||
QString filename;
|
QString filename;
|
||||||
QString shortfn;
|
QString shortfn;
|
||||||
Ui::OptionsDialog *ui;
|
Ui::OptionsDialog *ui;
|
||||||
AnalThread *analThread;
|
AnalThread analThread;
|
||||||
MainWindow *w;
|
MainWindow *w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user