replaced pointer by smart pointers

This commit is contained in:
2018-12-28 14:17:47 +01:00
parent 07205459d8
commit d4b4a37847
7 changed files with 77 additions and 68 deletions

View File

@@ -15,7 +15,7 @@ using std::endl;
using std::string;
using std::vector;
Training::Training(QWidget * parent, DataBase * db)
Training::Training(QWidget * parent, std::shared_ptr<DataBase> db)
: QMainWindow(parent), ui(new Ui::Training) {
ui->setupUi(this);
this->db = db;
@@ -38,12 +38,12 @@ Training::Training(QWidget * parent, DataBase * db)
started = true;
paused = false;
this->Hardware = new HardwareSetup;
this->Hardware = std::make_shared<HardwareSetup>();
Hardware->start();
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
QObject::connect(Hardware.get(), SIGNAL(Dea(int, int)), this,
SLOT(deaSlot(int, int)));
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
QObject::connect(Hardware.get(), SIGNAL(Shell(int, int)), this,
SLOT(shellSlot(int, int)));
// QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this,
// SLOT(prepareNextRace())); QObject::connect(this->ui->pBStop,
@@ -255,6 +255,7 @@ void Training::shellSlot(int time, int sector) {
}
void Training::closeEvent(QCloseEvent * event) {
Hardware->setStop();
this->close();
Q_UNUSED(event);
}
@@ -362,6 +363,5 @@ Training::~Training() {
cout << "destr Training" << endl;
this->Hardware->setStop();
usleep(1000000);
delete this->Hardware;
delete ui;
}